mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-05-28 21:41:22 +08:00
Update code.gitea.io/git (#1824)
* Update code.gitea.io/git * Update function calls * govendor fetch
This commit is contained in:
14
vendor/code.gitea.io/git/repo_branch.go
generated
vendored
14
vendor/code.gitea.io/git/repo_branch.go
generated
vendored
@ -66,19 +66,15 @@ func (repo *Repository) SetDefaultBranch(name string) error {
|
||||
|
||||
// GetBranches returns all branches of the repository.
|
||||
func (repo *Repository) GetBranches() ([]string, error) {
|
||||
stdout, err := NewCommand("show-ref", "--heads").RunInDir(repo.Path)
|
||||
stdout, err := NewCommand("for-each-ref", "--format=%(refname)", BranchPrefix).RunInDir(repo.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
infos := strings.Split(stdout, "\n")
|
||||
branches := make([]string, len(infos)-1)
|
||||
for i, info := range infos[:len(infos)-1] {
|
||||
fields := strings.Fields(info)
|
||||
if len(fields) != 2 {
|
||||
continue // NOTE: I should believe git will not give me wrong string.
|
||||
}
|
||||
branches[i] = strings.TrimPrefix(fields[1], BranchPrefix)
|
||||
refs := strings.Split(stdout, "\n")
|
||||
branches := make([]string, len(refs)-1)
|
||||
for i, ref := range refs[:len(refs)-1] {
|
||||
branches[i] = strings.TrimPrefix(ref, BranchPrefix)
|
||||
}
|
||||
return branches, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user