Skip to content

Commit

Permalink
git: Added an example for Repository.Branches
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmatthiggins committed May 5, 2024
1 parent bdb35e1 commit c571526
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ func ExampleRepository_References() {

}

func ExampleRepository_Branches() {
r, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: "https://github.com/git-fixtures/basic.git",
})

branches, _ := r.Branches()
branches.ForEach(func(branch *plumbing.Reference) error {
fmt.Println(branch.Hash().String(), branch.Name())
return nil
})

// Example Output:
// 6ecf0ef2c2dffb796033e5a02219af86ec6584e5 refs/heads/master
}

func ExampleRepository_CreateRemote() {
r, _ := git.Init(memory.NewStorage(), nil)

Expand Down

0 comments on commit c571526

Please sign in to comment.