Skip to content

Commit f95fb7d

Browse files
committed
Fix checks in PR for empty commits go-gitea#19603
* Fixes issue go-gitea#19603 * fill HeadCommitID in PullRequest * compare real commits ID as check for merging
1 parent b01dce2 commit f95fb7d

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

routers/web/repo/pull.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
12101210
BaseRepo: repo,
12111211
MergeBase: ci.CompareInfo.MergeBase,
12121212
Type: issues_model.PullRequestGitea,
1213+
HeadCommitID: ci.CompareInfo.HeadCommitID,
12131214
AllowMaintainerEdit: form.AllowMaintainerEdit,
12141215
}
12151216
// FIXME: check error in the case two people send pull request at almost same time, give nice error prompt

services/pull/patch.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,9 @@ func checkConflicts(ctx context.Context, pr *issues_model.PullRequest, gitRepo *
284284
}
285285

286286
if !conflict {
287-
var treeHash string
288-
treeHash, _, err = git.NewCommand(ctx, "write-tree").RunStdString(&git.RunOpts{Dir: tmpBasePath})
289-
if err != nil {
290-
return false, err
291-
}
292-
treeHash = strings.TrimSpace(treeHash)
293-
baseTree, err := gitRepo.GetTree("base")
294-
if err != nil {
295-
return false, err
296-
}
297-
if treeHash == baseTree.ID.String() {
298-
log.Debug("PullRequest[%d]: Patch is empty - ignoring", pr.ID)
287+
log.Info("PullRequest[%d]: Head SHA: %s, Merge base SHA: %s", pr.ID, pr.HeadCommitID, pr.MergeBase)
288+
if pr.HeadCommitID == pr.MergeBase {
289+
log.Debug("PullRequest[%d]: Commits are equal - ignoring", pr.ID)
299290
pr.Status = issues_model.PullRequestStatusEmpty
300291
}
301292

0 commit comments

Comments
 (0)