Skip to content

Commit 9e6169c

Browse files
committed
Add test for same commits in PR
* added explaining comment into patch.go * change log.info into log.debug
1 parent 4aab46f commit 9e6169c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

integrations/pull_status_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,27 @@ func TestPullCreate_EmptyChangesWithDifferentCommits(t *testing.T) {
134134
assert.Contains(t, text, "This pull request can be merged automatically.")
135135
})
136136
}
137+
138+
func TestPullCreate_EmptyChangesWithSameCommits(t *testing.T) {
139+
onGiteaRun(t, func(t *testing.T, u *url.URL) {
140+
session := loginUser(t, "user1")
141+
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
142+
testCreateBranch(t, session, "user1", "repo1", "branch/master", "status1", http.StatusSeeOther)
143+
144+
url := path.Join("user1", "repo1", "compare", "master...status1")
145+
req := NewRequestWithValues(t, "POST", url,
146+
map[string]string{
147+
"_csrf": GetCSRF(t, session, url),
148+
"title": "pull request from status1",
149+
},
150+
)
151+
session.MakeRequest(t, req, http.StatusSeeOther)
152+
153+
req = NewRequest(t, "GET", "/user1/repo1/pulls/1")
154+
resp := session.MakeRequest(t, req, http.StatusOK)
155+
doc := NewHTMLParser(t, resp.Body)
156+
157+
text := strings.TrimSpace(doc.doc.Find(".merge-section").Text())
158+
assert.Contains(t, text, "This branch is equal with the target branch.")
159+
})
160+
}

services/pull/patch.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,13 @@ func checkConflicts(ctx context.Context, pr *issues_model.PullRequest, gitRepo *
284284
}
285285

286286
if !conflict {
287-
log.Info("PullRequest[%d]: Head SHA: %s, Merge base SHA: %s", pr.ID, pr.HeadCommitID, pr.MergeBase)
287+
log.Debug("PullRequest[%d]: Head SHA: %s, Merge base SHA: %s", pr.ID, pr.HeadCommitID, pr.MergeBase)
288288
if pr.HeadCommitID == pr.MergeBase {
289+
// Merge must continue if commits SHA are different, even if content is same
290+
// Reason: gitflow and merging master back into develop, where is high possiblity, there are no changes
291+
// but just commit saying "Merge branch". And this meta commit can be also tagged,
292+
// so we need to have this meta commit also in develop branch.
293+
289294
log.Debug("PullRequest[%d]: Commits are equal - ignoring", pr.ID)
290295
pr.Status = issues_model.PullRequestStatusEmpty
291296
}

0 commit comments

Comments
 (0)