forked from forgejo/forgejo
Update code.gitea.io/git (#1824)
* Update code.gitea.io/git * Update function calls * govendor fetch
This commit is contained in:
parent
367ff327ed
commit
474d636794
11 changed files with 209 additions and 126 deletions
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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue