feat(open): prefix solutions with common header

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-10-15 15:41:17 +02:00
parent a869a3ebf8
commit 10a32ccbbd
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -32,6 +32,12 @@ var (
} }
) )
func PathFromBranchName(branch string) string {
task := strings.Split(branch, ".")[0]
source_file := fmt.Sprintf("%s.%s", strings.SplitN(task, "_", 2)[1], config.Language.DefaultSuffix)
return fmt.Sprintf("%s/%s", branch, source_file)
}
func ProcessBranches(client *gitea.Client, milestone *gitea.Milestone, branches []*gitea.Branch) { func ProcessBranches(client *gitea.Client, milestone *gitea.Milestone, branches []*gitea.Branch) {
for _, branch := range branches { for _, branch := range branches {
if !strings.HasPrefix(branch.Name, milestone.Title) { if !strings.HasPrefix(branch.Name, milestone.Title) {
@ -47,6 +53,21 @@ func ProcessBranches(client *gitea.Client, milestone *gitea.Milestone, branches
}) })
core.ExitOnError("Couldn't create PR", err) core.ExitOnError("Couldn't create PR", err)
_, _, err = client.CreatePullReview(config.Gitea.Owner, config.Gitea.Repository, pr.ID, gitea.CreatePullReviewOptions{
State: gitea.ReviewStatePending,
Body: "",
CommitID: pr.Head.Sha,
Comments: []gitea.CreatePullReviewComment{
gitea.CreatePullReviewComment{
Path: PathFromBranchName(branch.Name),
Body: config.Prefix,
OldLineNum: 0,
NewLineNum: 1,
},
},
})
core.ExitOnError("Couldn't create a PR review comment", err)
fmt.Printf("Created PR #%s\n", pr.ID) fmt.Printf("Created PR #%s\n", pr.ID)
} }
} }