mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-18 21:25:07 +02:00
Use new MergeBase method
This commit is contained in:
@@ -18,32 +18,6 @@ import (
|
||||
"code.gitea.io/gitea/modules/git/gitcmd"
|
||||
)
|
||||
|
||||
// GetMergeBase checks and returns merge base of two branches and the reference used as base.
|
||||
func (repo *Repository) GetMergeBase(tmpRemote, base, head string) (string, string, error) {
|
||||
if tmpRemote == "" {
|
||||
tmpRemote = "origin"
|
||||
}
|
||||
|
||||
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 := gitcmd.NewCommand("fetch", "--no-tags").
|
||||
AddDynamicArguments(tmpRemote).
|
||||
AddDashesAndList(base + ":" + tmpBaseName).
|
||||
WithDir(repo.Path).
|
||||
RunStdString(repo.Ctx)
|
||||
if err == nil {
|
||||
base = tmpBaseName
|
||||
}
|
||||
}
|
||||
|
||||
stdout, _, err := gitcmd.NewCommand("merge-base").
|
||||
AddDashesAndList(base, head).
|
||||
WithDir(repo.Path).
|
||||
RunStdString(repo.Ctx)
|
||||
return strings.TrimSpace(stdout), base, err
|
||||
}
|
||||
|
||||
type lineCountWriter struct {
|
||||
numLines int
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user