diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-04-21 21:55:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-21 22:55:45 +0100 |
commit | ebe569a268bbe71bf2bc30cd2829227700688b57 (patch) | |
tree | e4ba88d01dbaaee73135b8f61f52ae78487c0383 /models | |
parent | 3ec1b6c2238c9eb46709091567eb2564aec86d99 (diff) | |
download | gitea-ebe569a268bbe71bf2bc30cd2829227700688b57.tar.gz gitea-ebe569a268bbe71bf2bc30cd2829227700688b57.zip |
Set correct PR status on 3way on conflict checking (#19457)
* Set correct PR status on 3way on conflict checking
- When 3-way merge is enabled for conflict checking, it has a new
interesting behavior that it doesn't return any error when it found a
conflict, so we change the condition to not check for the error, but
instead check if conflictedfiles is populated, this fixes a issue
whereby PR status wasn't correctly on conflicted PR's.
- Refactor the mergeable property(which was incorrectly set and lead me this
bug) to be more maintainable.
- Add a dedicated test for conflicting checking, so it should prevent
future issues with this.
* Fix linter
Diffstat (limited to 'models')
-rw-r--r-- | models/pull.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/models/pull.go b/models/pull.go index 439005deb4..ac44ebf0be 100644 --- a/models/pull.go +++ b/models/pull.go @@ -701,3 +701,14 @@ func (pr *PullRequest) GetHeadBranchHTMLURL() string { } return pr.HeadRepo.HTMLURL() + "/src/branch/" + util.PathEscapeSegments(pr.HeadBranch) } + +// Mergeable returns if the pullrequest is mergeable. +func (pr *PullRequest) Mergeable() bool { + // If a pull request isn't mergable if it's: + // - Being conflict checked. + // - Has a conflict. + // - Received a error while being conflict checked. + // - Is a work-in-progress pull request. + return pr.Status != PullRequestStatusChecking && pr.Status != PullRequestStatusConflict && + pr.Status != PullRequestStatusError && !pr.IsWorkInProgress() +} |