mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-19 09:33:54 +09:00
Backport #39831 by @lunny When pushing the merge commit to the base repo fails (e.g. non-fast-forward), the merge intent recorded by https://github.com/go-gitea/gitea/pull/39442 is left behind. `merged_commit_id` then points to a commit that does not exist in the base repo, and `git branch --contains` fails with `no such commit`, so the PR can never be checked or merged again. - Clear the recorded merge intent if the push fails and the commit is not on the base branch - `IsCommitInBranch` now returns false for a missing commit, so already-stuck PRs recover on the next check Fixes: https://github.com/go-gitea/gitea/issues/39824 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
co-authored by
Lunny Xiao
silverwind
parent
cfcbdf41e2
commit
6bc0e8cd57
@@ -70,6 +70,20 @@ func TestGetCommitWithBadCommitID(t *testing.T) {
|
||||
assert.True(t, IsErrNotExist(err))
|
||||
}
|
||||
|
||||
func TestIsCommitInRepo(t *testing.T) {
|
||||
bareRepo1, err := OpenRepositoryLocal(t.Context(), filepath.Join(testReposDir, "repo1_bare"))
|
||||
assert.NoError(t, err)
|
||||
defer bareRepo1.Close()
|
||||
|
||||
exist, err := IsCommitInRepo(t.Context(), bareRepo1, "2839944139e0de9737a044f78b0e4b40d989a9e3")
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, exist)
|
||||
|
||||
exist, err = IsCommitInRepo(t.Context(), bareRepo1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, exist)
|
||||
}
|
||||
|
||||
func TestIsCommitInBranch(t *testing.T) {
|
||||
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
|
||||
bareRepo1, err := OpenRepositoryLocal(t.Context(), bareRepo1Path)
|
||||
@@ -83,6 +97,10 @@ func TestIsCommitInBranch(t *testing.T) {
|
||||
result, err = IsCommitInBranch(t.Context(), bareRepo1, "2839944139e0de9737a044f78b0e4b40d989a9e3", "branch2")
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, result)
|
||||
|
||||
result, err = IsCommitInBranch(t.Context(), bareRepo1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "branch1")
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, result)
|
||||
}
|
||||
|
||||
func TestRepository_CommitsBetween(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user