diff options
Diffstat (limited to 'vendor/code.gitea.io/git/repo_branch.go')
-rw-r--r-- | vendor/code.gitea.io/git/repo_branch.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/vendor/code.gitea.io/git/repo_branch.go b/vendor/code.gitea.io/git/repo_branch.go index f7252bb0e9..f2e9f43cdb 100644 --- a/vendor/code.gitea.io/git/repo_branch.go +++ b/vendor/code.gitea.io/git/repo_branch.go @@ -11,7 +11,8 @@ import ( "github.com/mcuadros/go-version" ) -const BRANCH_PREFIX = "refs/heads/" +// BranchPrefix base dir of the branch information file store on git +const BranchPrefix = "refs/heads/" // IsReferenceExist returns true if given reference exists in the repository. func IsReferenceExist(repoPath, name string) bool { @@ -21,9 +22,10 @@ func IsReferenceExist(repoPath, name string) bool { // IsBranchExist returns true if given branch exists in the repository. func IsBranchExist(repoPath, name string) bool { - return IsReferenceExist(repoPath, BRANCH_PREFIX+name) + return IsReferenceExist(repoPath, BranchPrefix+name) } +// IsBranchExist returns true if given branch exists in current repository. func (repo *Repository) IsBranchExist(name string) bool { return IsBranchExist(repo.Path, name) } @@ -42,12 +44,12 @@ func (repo *Repository) GetHEADBranch() (*Branch, error) { } stdout = strings.TrimSpace(stdout) - if !strings.HasPrefix(stdout, BRANCH_PREFIX) { + if !strings.HasPrefix(stdout, BranchPrefix) { return nil, fmt.Errorf("invalid HEAD branch: %v", stdout) } return &Branch{ - Name: stdout[len(BRANCH_PREFIX):], + Name: stdout[len(BranchPrefix):], Path: stdout, }, nil } @@ -58,7 +60,7 @@ func (repo *Repository) SetDefaultBranch(name string) error { return ErrUnsupportedVersion{"1.7.10"} } - _, err := NewCommand("symbolic-ref", "HEAD", BRANCH_PREFIX+name).RunInDir(repo.Path) + _, err := NewCommand("symbolic-ref", "HEAD", BranchPrefix+name).RunInDir(repo.Path) return err } @@ -76,12 +78,12 @@ func (repo *Repository) GetBranches() ([]string, error) { if len(fields) != 2 { continue // NOTE: I should believe git will not give me wrong string. } - branches[i] = strings.TrimPrefix(fields[1], BRANCH_PREFIX) + branches[i] = strings.TrimPrefix(fields[1], BranchPrefix) } return branches, nil } -// Option(s) for delete branch +// DeleteBranchOptions Option(s) for delete branch type DeleteBranchOptions struct { Force bool } |