8000 Can't delete a branch that for sure exists · Issue #1189 · go-git/go-git · GitHub
[go: up one dir, main page]

Skip to content
Can't delete a branch that for sure exists #1189
Open
@shaneikennedy

Description

@shaneikennedy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is neededno-autocloseIssues/PRs to be ignored by stale bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0