aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/pull.go
diff options
context:
space:
mode:
authorIng. Jaroslav Šafka <devel@safka.org>2022-07-13 19:36:23 +0200
committerGitHub <noreply@github.com>2022-07-13 18:36:23 +0100
commit92a43d577d1fbe8e901c303f98a93e0c035de066 (patch)
treecd4754d9f8232d4754096646ca369bfeccf8eb49 /models/issues/pull.go
parent66686f6d0eeb24fdfe709dbc0a7d5aa67caa54f9 (diff)
downloadgitea-92a43d577d1fbe8e901c303f98a93e0c035de066.tar.gz
gitea-92a43d577d1fbe8e901c303f98a93e0c035de066.zip
Fix checks in PR for empty commits (#20290) (#20352)
Backport #20290 * Fix #19603 * fill HeadCommitID in PullRequest * compare real commits ID as check for merging Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'models/issues/pull.go')
-rw-r--r--models/issues/pull.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/models/issues/pull.go b/models/issues/pull.go
index f2ca19b03e..0524acb211 100644
--- a/models/issues/pull.go
+++ b/models/issues/pull.go
@@ -122,6 +122,7 @@ const (
PullRequestStatusManuallyMerged
PullRequestStatusError
PullRequestStatusEmpty
+ PullRequestStatusAncestor
)
// PullRequestFlow the flow of pull request
@@ -423,6 +424,11 @@ func (pr *PullRequest) IsEmpty() bool {
return pr.Status == PullRequestStatusEmpty
}
+// IsAncestor returns true if the Head Commit of this PR is an ancestor of the Base Commit
+func (pr *PullRequest) IsAncestor() bool {
+ return pr.Status == PullRequestStatusAncestor
+}
+
// SetMerged sets a pull request to merged and closes the corresponding issue
func (pr *PullRequest) SetMerged(ctx context.Context) (bool, error) {
if pr.HasMerged {