зеркало из https://github.com/golang/build.git
cmd/coordinator: avoid ambiguous branch names
When trying to resolve a branch name, if there is a remote or tag of the same name, git cannot resolve it and issues an warning that "refname 'BRANCH' is ambiguous." This was discovered in gccgo's watcher process on the branch 'asan' which is also the name of a tag in the gcc repo. To disambiguate between a remote and a tag, any refname can be prepended with "heads/" or "tags/", respectively. Change-Id: I16679f5249a5f22df59ab3a0ed49459bbbf5367b Reviewed-on: https://go-review.googlesource.com/16083 Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
Родитель
23c48177a6
Коммит
4ec6dec7c4
|
@ -328,7 +328,7 @@ func (r *Repo) postNewCommits(b *Branch) error {
|
|||
}
|
||||
} else {
|
||||
// Find the commit that this branch forked from.
|
||||
base, err := r.mergeBase(b.Name, master)
|
||||
base, err := r.mergeBase("heads/"+b.Name, master)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -460,19 +460,26 @@ func (r *Repo) update(noisy bool) error {
|
|||
b := r.branches[name]
|
||||
|
||||
// Find all unseen commits on this branch.
|
||||
revspec := name
|
||||
revspec := "heads/" + name
|
||||
if b != nil {
|
||||
// If we know about this branch,
|
||||
// only log commits down to the known head.
|
||||
revspec = b.Head.Hash + ".." + name
|
||||
revspec = b.Head.Hash + ".." + revspec
|
||||
} else if name != master {
|
||||
// If this is an unknown non-master branch,
|
||||
// log up to where it forked from master.
|
||||
base, err := r.mergeBase(name, master)
|
||||
base, err := r.mergeBase(revspec, master)
|
||||
if base == "" {
|
||||
// This branch did not fork from master so we
|
||||
// don't care about it.
|
||||
delete(r.branches, name)
|
||||
log.Printf("Found independent branch %s. This branch will not be watched.", name)
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
revspec = base + ".." + name
|
||||
revspec = base + ".." + revspec
|
||||
}
|
||||
log, err := r.log("--topo-order", revspec)
|
||||
if err != nil {
|
||||
|
@ -610,7 +617,7 @@ func (r *Repo) mergeBase(a, b string) (string, error) {
|
|||
cmd.Dir = r.root
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("git merge-base: %v", err)
|
||||
return "", fmt.Errorf("git merge-base %s..%s: %v", a, b, err)
|
||||
}
|
||||
return string(bytes.TrimSpace(out)), nil
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче