From 66ee9b87f9aaabef836ec72bfaf8032b359b29c1 Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 15 Jan 2020 08:32:57 +0000 Subject: Add require signed commit for protected branch (#9708) * Add require signed commit for protected branch * Fix fmt * Make editor show if they will be signed * bugfix * Add basic merge check and better information for CRUD * linting comment * Add descriptors to merge signing * Slight refactor * Slight improvement to appearances * Handle Merge API * manage CRUD API * Move error to error.go * Remove fix to delete.go * prep for merge * need to tolerate \r\n in message * check protected branch before trying to load it * Apply suggestions from code review Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * fix commit-reader Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> --- templates/repo/editor/commit_form.tmpl | 17 ++++++++-- templates/repo/issue/view_content/pull.tmpl | 46 +++++++++++++++++++++------ templates/repo/settings/protected_branch.tmpl | 9 +++++- 3 files changed, 59 insertions(+), 13 deletions(-) (limited to 'templates') diff --git a/templates/repo/editor/commit_form.tmpl b/templates/repo/editor/commit_form.tmpl index 2ff08e3931..1915e9be21 100644 --- a/templates/repo/editor/commit_form.tmpl +++ b/templates/repo/editor/commit_form.tmpl @@ -1,7 +1,11 @@
-

{{.i18n.Tr "repo.editor.commit_changes"}}

+

{{- if .CanCommitToBranch.WillSign}} + {{.i18n.Tr "repo.editor.commit_signed_changes"}} + {{- else}} + {{.i18n.Tr "repo.editor.commit_changes"}} + {{- end}}

@@ -10,11 +14,20 @@
-
+
diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 7073312b1f..1bf0fa7864 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -48,6 +48,7 @@ {{else if .IsBlockedByApprovals}}red {{else if .IsBlockedByRejection}}red {{else if and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}red + {{else if and .RequireSigned (not .WillSign)}}}red {{else if .Issue.PullRequest.IsChecking}}yellow {{else if .Issue.PullRequest.CanAutoMerge}}green {{else}}red{{end}}"> @@ -93,49 +94,69 @@
{{else if .IsPullRequestBroken}}
- + {{$.i18n.Tr "repo.pulls.data_broken"}}
{{else if .IsPullWorkInProgress}}
- + {{$.i18n.Tr "repo.pulls.cannot_merge_work_in_progress" .WorkInProgressPrefix | Str2html}}
{{else if .Issue.PullRequest.IsChecking}}
- + {{$.i18n.Tr "repo.pulls.is_checking"}}
{{else if .Issue.PullRequest.CanAutoMerge}} {{if .IsBlockedByApprovals}}
- + {{$.i18n.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .Issue.PullRequest.ProtectedBranch.RequiredApprovals}}
{{else if .IsBlockedByRejection}}
- + {{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
{{else if and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}
- + {{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
+ {{else if and .RequireSigned (not .WillSign)}} +
+ + {{$.i18n.Tr "repo.pulls.require_signed_wont_sign"}} +
+
+ + {{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }} +
{{end}} - {{$notAllOk := or .IsBlockedByApprovals .IsBlockedByRejection (and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess))}} - {{if or $.IsRepoAdmin (not $notAllOk)}} + {{$notAllOk := or .IsBlockedByApprovals .IsBlockedByRejection (and .RequireSigned (not .WillSign)) (and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess))}} + {{if and (or $.IsRepoAdmin (not $notAllOk)) (or (not .RequireSigned) .WillSign)}} {{if $notAllOk}}
- + {{$.i18n.Tr "repo.pulls.required_status_check_administrator"}}
{{else}}
- + {{$.i18n.Tr "repo.pulls.can_auto_merge_desc"}}
{{end}} + {{if .WillSign}} +
+ + {{$.i18n.Tr "repo.signing.will_sign" .SigningKey}} +
+ {{else}} +
+ + {{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }} +
+ {{end}} {{if .AllowMerge}} {{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}} {{$approvers := .Issue.PullRequest.GetApprovers}} @@ -282,6 +303,11 @@ {{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
+ {{else if and .RequireSigned (not .WillSign)}} +
+ + {{$.i18n.Tr "repo.pulls.require_signed_wont_sign"}} +
{{else}}
diff --git a/templates/repo/settings/protected_branch.tmpl b/templates/repo/settings/protected_branch.tmpl index c6701ce8a9..b4c65f7830 100644 --- a/templates/repo/settings/protected_branch.tmpl +++ b/templates/repo/settings/protected_branch.tmpl @@ -210,7 +210,7 @@

{{.i18n.Tr "repo.settings.block_rejected_reviews_desc"}}

-
+
@@ -218,6 +218,13 @@

{{.i18n.Tr "repo.settings.dismiss_stale_approvals_desc"}}

+
+
+ + +

{{.i18n.Tr "repo.settings.require_signed_commits_desc"}}

+
+
-- cgit v1.2.3