Skip to content

Commit 4857069

Browse files
committed
Add StatusAncestor
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 19f28cc commit 4857069

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

models/issues/pull.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ const (
122122
PullRequestStatusManuallyMerged
123123
PullRequestStatusError
124124
PullRequestStatusEmpty
125+
PullRequestStatusAncestor
125126
)
126127

127128
// PullRequestFlow the flow of pull request
@@ -425,7 +426,7 @@ func (pr *PullRequest) IsEmpty() bool {
425426

426427
// IsAncestor returns true if the Head Commit of this PR is an ancestor of the Base Commit
427428
func (pr *PullRequest) IsAncestor() bool {
428-
return pr.HeadCommitID == pr.MergeBase
429+
return pr.Status == PullRequestStatusAncestor
429430
}
430431

431432
// SetMerged sets a pull request to merged and closes the corresponding issue

services/pull/patch.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ func TestPatch(pr *issues_model.PullRequest) error {
8787
}
8888
}
8989
pr.MergeBase = strings.TrimSpace(pr.MergeBase)
90+
if pr.HeadCommitID, err = gitRepo.GetBranchCommitID("tracking"); err != nil {
91+
return fmt.Errorf("GetBranchCommitID: can't find commit ID for head: %w", err)
92+
}
9093

9194
if pr.HeadCommitID == pr.MergeBase {
92-
pr.Status = issues_model.PullRequestStatusEmpty
95+
pr.Status = issues_model.PullRequestStatusAncestor
9396
return nil
9497
}
9598

0 commit comments

Comments
 (0)