keep switching over to the protobuf
This commit is contained in:
parent
010791e828
commit
c9149bbb13
44
branches.go
44
branches.go
|
@ -2,6 +2,7 @@ package gitpb
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -9,18 +10,6 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// returns true if 'git pull' will work
|
||||
func (repo *Repo) IsBranchRemote(branchname string) bool {
|
||||
if branchname == "" {
|
||||
return false
|
||||
}
|
||||
if repo.Exists(filepath.Join(".git/refs/remotes/origin", branchname)) {
|
||||
// todo: actually use .git/config
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// returns true if 'git pull' will work
|
||||
func (repo *Repo) ExistsUserBranchRemote() bool {
|
||||
branchname := repo.GetUserBranchName()
|
||||
|
@ -40,11 +29,7 @@ func (repo *Repo) ExistsUserBranch() bool {
|
|||
// todo: actually use .git/config
|
||||
return true
|
||||
}
|
||||
if repo.Exists(filepath.Join(".git/refs/remote/origin", branchname)) {
|
||||
// todo: actually use .git/config
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return repo.IsBranchRemote(branchname)
|
||||
}
|
||||
|
||||
// returns true if the devel branch exists
|
||||
|
@ -57,11 +42,7 @@ func (repo *Repo) ExistsDevelBranch() bool {
|
|||
// todo: actually use .git/config
|
||||
return true
|
||||
}
|
||||
if repo.Exists(filepath.Join(".git/refs/remote/origin", branchname)) {
|
||||
// todo: actually use .git/config
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return repo.IsBranchRemote(branchname)
|
||||
}
|
||||
|
||||
func (repo *Repo) GetBranchHash(branchname string) string {
|
||||
|
@ -146,3 +127,22 @@ func (repo *Repo) GetTagHash(t string) string {
|
|||
|
||||
return result.Stdout[0]
|
||||
}
|
||||
|
||||
// deletes the devel local branch if it is a subset of the remote devel branch
|
||||
func (repo *Repo) DeleteLocalDevelBranch() error {
|
||||
branch := repo.GetDevelBranchName()
|
||||
remote := filepath.Join("origin", branch)
|
||||
|
||||
if !repo.IsDevelRemote() {
|
||||
return fmt.Errorf("no remote branch")
|
||||
}
|
||||
b1 := repo.CountDiffObjects(branch, remote) // should be zero
|
||||
if b1 == 0 {
|
||||
cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
|
||||
log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd)
|
||||
err := repo.RunVerbose(cmd)
|
||||
return err
|
||||
} else {
|
||||
return fmt.Errorf("local branch has patches not in remote")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,23 @@ func (repo *Repo) DevelHash() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// this is the correct way. uses 'git show-ref'
|
||||
func (repo *Repo) IsBranchRemote(brname string) bool {
|
||||
if repo.Tags == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
brname = "refs/remotes/origin/" + brname
|
||||
ref := repo.Tags.FindByRefname(brname)
|
||||
if ref == nil {
|
||||
// log.Info("did not found refname!!!!!!!!", brname)
|
||||
return false
|
||||
}
|
||||
// log.Info("found refname!!!!!!!!")
|
||||
return true
|
||||
}
|
||||
|
||||
// this is the correct way. uses 'git show-ref'
|
||||
func (repo *Repo) IsDevelRemote() bool {
|
||||
if repo.Tags == nil {
|
||||
return false
|
||||
|
@ -30,10 +47,10 @@ func (repo *Repo) IsDevelRemote() bool {
|
|||
refname := "refs/remotes/origin/" + devname
|
||||
ref := repo.Tags.FindByRefname(refname)
|
||||
if ref == nil {
|
||||
log.Info("did not found refname!!!!!!!!", refname)
|
||||
// log.Info("did not found refname!!!!!!!!", refname)
|
||||
return false
|
||||
}
|
||||
log.Info("found refname!!!!!!!!")
|
||||
// log.Info("found refname!!!!!!!!")
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue