gitpb/branches.go

53 lines
1.1 KiB
Go

package gitpb
import (
"path/filepath"
)
// 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()
if repo.IsBranchRemote(branchname) {
return true
}
return false
}
// returns true if the user branch exists
func (repo *Repo) ExistsUserBranch() bool {
if repo.GetUserBranchName() == "" {
return false
}
branchname := repo.GetUserBranchName()
if repo.Exists(filepath.Join(".git/refs/heads", branchname)) {
// todo: actually use .git/config
return true
}
return false
}
// returns true if the devel branch exists
func (repo *Repo) ExistsDevelBranch() bool {
if repo.GetDevelBranchName() == "" {
return false
}
branchname := repo.GetDevelBranchName()
if repo.Exists(filepath.Join(".git/refs/heads", branchname)) {
// todo: actually use .git/config
return true
}
return false
}