-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: output each PR# along with issues (#43)
- Loading branch information
Showing
3 changed files
with
80 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ type Config struct { | |
Host string | ||
IncludeIssuePRAuthors bool | ||
IncludeIssues bool | ||
IncludeIssuePRs bool | ||
IncludePRs bool | ||
ExcludeLabels []string | ||
ChangeTypesByLabel change.TypeSet | ||
|
@@ -306,18 +307,19 @@ func createChangesFromIssues(config Config, allMergedPRs []ghPullRequest, issues | |
}, | ||
} | ||
|
||
if config.IncludeIssuePRAuthors { | ||
for _, pr := range allMergedPRs { | ||
if pr.Author == "" { | ||
continue | ||
if config.IncludeIssuePRs || config.IncludeIssuePRAuthors { | ||
for _, pr := range getLinkedPRs(allMergedPRs, issue) { | ||
if config.IncludeIssuePRs { | ||
references = append(references, change.Reference{ | ||
Text: fmt.Sprintf("PR #%d", pr.Number), | ||
URL: pr.URL, | ||
}) | ||
} | ||
for _, linkedIssue := range pr.LinkedIssues { | ||
if linkedIssue.URL == issue.URL { | ||
references = append(references, change.Reference{ | ||
Text: pr.Author, | ||
URL: fmt.Sprintf("https://%s/%s", config.Host, pr.Author), | ||
}) | ||
} | ||
if config.IncludeIssuePRAuthors && pr.Author != "" { | ||
references = append(references, change.Reference{ | ||
Text: pr.Author, | ||
URL: fmt.Sprintf("https://%s/%s", config.Host, pr.Author), | ||
}) | ||
} | ||
} | ||
} | ||
|
@@ -335,6 +337,17 @@ func createChangesFromIssues(config Config, allMergedPRs []ghPullRequest, issues | |
return changes | ||
} | ||
|
||
func getLinkedPRs(allMergedPRs []ghPullRequest, issue ghIssue) (linked []ghPullRequest) { | ||
for _, pr := range allMergedPRs { | ||
for _, linkedIssue := range pr.LinkedIssues { | ||
if linkedIssue.URL == issue.URL { | ||
linked = append(linked, pr) | ||
} | ||
} | ||
} | ||
return linked | ||
} | ||
|
||
func extractGithubUserAndRepo(u string) (string, string) { | ||
switch { | ||
// e.g. [email protected]:anchore/chronicle.git | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters