Open
Description
Repro
repoDir = "pathtoexistingrepo"
r, err := git.PlainOpen(repoDir)
if err != nil {
return err
}
branchToDelete = "test"
branches, err := r.Branches()
err = branches.ForEach(func(b *plumbing.Reference) error {
if b.Name().String() == branchToDelete {
fmt.Println("Found the branch")
err = r.DeleteBranch(b.Name().String())
if err != nil {
return err
}
}
return nil
})
if err != nil {
fmt.Println(err)
}
Output:
Found the branch // from the ForEach
Branch not found // err check at the end
Tried with b.Name().Short() as well, same result