Skip to content

Commit

Permalink
https://github.com/go-gitea/gitea/issues/22578#issuecomment-1444180053
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Jul 20, 2023
1 parent af22f33 commit 66b81c4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions modules/git/repo_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ func (repo *Repository) GetMergeBase(tmpRemote, base, head string) (string, stri
if tmpRemote != "origin" {
tmpBaseName := RemotePrefix + tmpRemote + "/tmp_" + base
// Fetch commit into a temporary branch in order to be able to handle commits and tags
_, _, err := NewCommand(repo.Ctx, "fetch", "--no-tags").AddDynamicArguments(tmpRemote).AddDashesAndList(base + ":" + tmpBaseName).RunStdString(&RunOpts{Dir: repo.Path})
if err == nil {
base = tmpBaseName
// --no-write-commit-graph: fetch will try to generate commit graph by default
// this process require a lock-file (objects/info/commit-graphs/commit-graph-chain.lock)
// and will make fetch return an error code if the file already exists
_, _, err := NewCommand(repo.Ctx, "fetch", "--no-write-commit-graph", "--no-tags").
AddDynamicArguments(tmpRemote).AddDashesAndList(base + ":" + tmpBaseName).
RunStdString(&RunOpts{Dir: repo.Path})
if err != nil {
logger.Error("Failed to fetch new remote for GetMergeBase %v", err)
return "", "", err
}
base = tmpBaseName
}

stdout, _, err := NewCommand(repo.Ctx, "merge-base").AddDashesAndList(base, head).RunStdString(&RunOpts{Dir: repo.Path})
Expand Down

0 comments on commit 66b81c4

Please sign in to comment.