Skip to content

Commit 0208f5b

Browse files
committed
Add ref issue when creating pull request from issue
1 parent 6b829f7 commit 0208f5b

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,7 @@ issues.maybefixed = May be fixed by %s
16271627
issues.create_branch_from_issue_success = Create branch %s from issue successfully
16281628
issues.pr.completed = Completed
16291629
issues.pr.conflicted = Merge conflicts
1630+
issues.pr.not_exist_issue = Reference issue does not exist.
16301631
issues.branch.latest = Latest commit %s
16311632
issues.link.created = Created %s
16321633
issues.num_participants = %d Participants

routers/web/repo/compare.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,21 @@ func CompareDiff(ctx *context.Context) {
845845
ctx.Data["AllowMaintainerEdit"] = false
846846
}
847847

848+
refIssueIndex := ctx.FormInt64("ref_issue_index")
849+
if refIssueIndex > 0 {
850+
refIssue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, refIssueIndex)
851+
if err != nil {
852+
ctx.Flash.Warning(ctx.Tr("repo.issues.pr.not_exist_issue"), true)
853+
} else {
854+
keyword := "Resolve"
855+
if len(setting.Repository.PullRequest.CloseKeywords) > 0 {
856+
keyword = setting.Repository.PullRequest.CloseKeywords[0]
857+
}
858+
ctx.Data["TitleQuery"] = fmt.Sprintf("%s %s", keyword, refIssue.Title)
859+
ctx.Data["BodyQuery"] = fmt.Sprintf("%s #%d", keyword, refIssueIndex)
860+
}
861+
}
862+
848863
ctx.HTML(http.StatusOK, tplCompare)
849864
}
850865

templates/repo/issue/view_content/sidebar_development.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</a>
3434
</div>
3535
<div class="tw-right">
36-
<a class="ui button mini compact basic icon" href="{{$.Issue.Repo.Link}}/compare/{{$.Issue.Repo.DefaultBranch}}...{{.Branch.Repo.FullName}}:{{.Branch.Name}}">
36+
<a class="ui button mini compact basic icon" href="{{$.Issue.Repo.Link}}/compare/{{$.Issue.Repo.DefaultBranch}}...{{.Branch.Repo.FullName}}:{{.Branch.Name}}?ref_issue_index={{$.Issue.Index}}">
3737
{{svg "octicon-git-pull-request"}}
3838
</a>
3939
</div>

0 commit comments

Comments
 (0)