summaryrefslogtreecommitdiff
path: root/branches.go
blob: 085380c59371091e5f3f53159891861e3fe4095d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
}