diff --git a/src/cmd/open.go b/src/cmd/open.go index e5a6d51..a1db161 100644 --- a/src/cmd/open.go +++ b/src/cmd/open.go @@ -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) { for _, branch := range branches { 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) + _, _, 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) } } \ No newline at end of file