From c571526c06accbdc246312ed5c786339a049d6de Mon Sep 17 00:00:00 2001 From: John Higgins Date: Sun, 5 May 2024 13:04:25 -0700 Subject: git: Added an example for Repository.Branches --- example_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/example_test.go b/example_test.go index 27ea4a2..7b6adc5 100644 --- a/example_test.go +++ b/example_test.go @@ -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) -- cgit