Skip to content

Commit 73e69da

Browse files
authored
[issuegenerator] remove pr section from issue body (#1244)
* remove pr section from issue body * fix lint
1 parent 4db05eb commit 73e69da

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: bug_fix
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. crosslink)
5+
component: issuegenerator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: removed pr section from autogenerated issue body.
9+
10+
# One or more tracking issues related to the change
11+
issues: [1243]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

issuegenerator/internal/github/client.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const (
3838
githubWorkflow = "GITHUB_ACTION"
3939
githubAPITokenKey = "GITHUB_TOKEN" // #nosec G101
4040
githubSHAKey = "GITHUB_SHA"
41-
githubRefKey = "GITHUB_REF"
4241

4342
githubOwner = "githubOwner"
4443
githubRepository = "githubRepository"
@@ -53,7 +52,6 @@ Auto-generated report for ${jobName} job build.
5352
5453
Link to failed build: ${linkToBuild}
5554
Commit: ${commit}
56-
PR: ${pr}
5755
5856
### Component(s)
5957
${component}
@@ -66,7 +64,6 @@ this issue is open, will be added as comments with more information to this issu
6664
issueCommentTemplate = `
6765
Link to latest failed build: ${linkToBuild}
6866
Commit: ${commit}
69-
PR: ${pr}
7067
7168
${failedTests}
7269
`
@@ -150,7 +147,6 @@ func getRequiredEnv() (map[string]string, error) {
150147
env[githubRunID] = os.Getenv(githubRunID)
151148
env[githubAPITokenKey] = os.Getenv(githubAPITokenKey)
152149
env[githubSHAKey] = os.Getenv(githubSHAKey)
153-
env[githubRefKey] = os.Getenv(githubRefKey)
154150

155151
for k, v := range env {
156152
if v == "" {
@@ -252,20 +248,21 @@ func templateHelper(env map[string]string, r report.Report) func(string) string
252248
trimmedModule := trimModule(env[githubOwner], env[githubRepository], r.Module)
253249
return getComponent(trimmedModule)
254250
case "commit":
255-
return env[githubSHAKey]
256-
case "pr":
257-
ref := env[githubRefKey]
258-
parts := strings.Split(ref, "/")
259-
if len(parts) == 4 && parts[1] == "pull" {
260-
return "#" + parts[2]
261-
}
262-
return fmt.Sprintf("N/A (github_ref: %q)", ref)
251+
return shortSha(env[githubSHAKey])
263252
default:
264253
return ""
265254
}
266255
}
267256
}
268257

258+
// shortSha returns the first 7 characters of a full Git commit SHA
259+
func shortSha(sha string) string {
260+
if len(sha) >= 7 {
261+
return sha[:7]
262+
}
263+
return sha
264+
}
265+
269266
// CreateIssue creates a new GitHub Issue corresponding to a build failure.
270267
func (c *Client) CreateIssue(ctx context.Context, r report.Report) *github.Issue {
271268
trimmedModule := trimModule(c.envVariables[githubOwner], c.envVariables[githubRepository], r.Module)

issuegenerator/internal/github/client_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func TestTemplateExpansion(t *testing.T) {
4040
githubRepository: "test-repo",
4141
githubRunID: "555555",
4242
githubSHAKey: "abcde12345",
43-
githubRefKey: "refs/pull/1234/merge",
4443
}
4544

4645
// Sort the reports by module name to ensure deterministic order
@@ -59,8 +58,7 @@ func TestTemplateExpansion(t *testing.T) {
5958
Auto-generated report for ` + "`test-ci`" + ` job build.
6059
6160
Link to failed build: https://github.com/test-org/test-repo/actions/runs/555555
62-
Commit: abcde12345
63-
PR: #1234
61+
Commit: abcde12
6462
6563
### Component(s)
6664
` + "package1" + `
@@ -83,8 +81,7 @@ this issue is open, will be added as comments with more information to this issu
8381
template: issueCommentTemplate,
8482
expected: `
8583
Link to latest failed build: https://github.com/test-org/test-repo/actions/runs/555555
86-
Commit: abcde12345
87-
PR: #1234
84+
Commit: abcde12
8885
8986
#### Test Failures
9087
- ` + "`TestFailure`" + `

0 commit comments

Comments
 (0)