@@ -25,31 +25,22 @@ func IsBranchExist(ctx context.Context, repoPath, name string) bool {
2525 return IsReferenceExist (ctx , repoPath , BranchPrefix + name )
2626}
2727
28- // Branch represents a Git branch.
29- type Branch struct {
30- Name string
31- Path string
32- }
33-
3428// GetHEADBranch returns corresponding branch of HEAD.
35- func (repo * Repository ) GetHEADBranch () (* Branch , error ) {
29+ func (repo * Repository ) GetHEADBranch () (string , error ) {
3630 if repo == nil {
37- return nil , fmt .Errorf ("nil repo" )
31+ return "" , fmt .Errorf ("nil repo" )
3832 }
3933 stdout , _ , err := NewCommand ("symbolic-ref" , "HEAD" ).RunStdString (repo .Ctx , & RunOpts {Dir : repo .Path })
4034 if err != nil {
41- return nil , err
35+ return "" , err
4236 }
4337 stdout = strings .TrimSpace (stdout )
4438
4539 if ! strings .HasPrefix (stdout , BranchPrefix ) {
46- return nil , fmt .Errorf ("invalid HEAD branch: %v" , stdout )
40+ return "" , fmt .Errorf ("invalid HEAD branch: %v" , stdout )
4741 }
4842
49- return & Branch {
50- Name : stdout [len (BranchPrefix ):],
51- Path : stdout ,
52- }, nil
43+ return stdout [len (BranchPrefix ):], nil
5344}
5445
5546func GetDefaultBranch (ctx context.Context , repoPath string ) (string , error ) {
@@ -65,32 +56,11 @@ func GetDefaultBranch(ctx context.Context, repoPath string) (string, error) {
6556}
6657
6758// GetBranch returns a branch by it's name
68- func (repo * Repository ) GetBranch (branch string ) (* Branch , error ) {
59+ func (repo * Repository ) GetBranch (branch string ) (string , error ) {
6960 if ! repo .IsBranchExist (branch ) {
70- return nil , ErrBranchNotExist {branch }
71- }
72- return & Branch {
73- Path : repo .Path ,
74- Name : branch ,
75- }, nil
76- }
77-
78- // GetBranches returns a slice of *git.Branch
79- func (repo * Repository ) GetBranches (skip , limit int ) ([]* Branch , int , error ) {
80- brs , countAll , err := repo .GetBranchNames (skip , limit )
81- if err != nil {
82- return nil , 0 , err
61+ return "" , ErrBranchNotExist {branch }
8362 }
84-
85- branches := make ([]* Branch , len (brs ))
86- for i := range brs {
87- branches [i ] = & Branch {
88- Path : repo .Path ,
89- Name : brs [i ],
90- }
91- }
92-
93- return branches , countAll , nil
63+ return branch , nil
9464}
9565
9666// DeleteBranchOptions Option(s) for delete branch
0 commit comments