aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Higgins <johnmatthiggins@gmail.com>2024-05-05 13:04:25 -0700
committerJohn Higgins <johnmatthiggins@gmail.com>2024-05-05 13:04:25 -0700
commitc571526c06accbdc246312ed5c786339a049d6de (patch)
treeb13e6a3ecf35ced02bb30012bdaef4615bcb5975
parentbdb35e1950b5829c88df134810a0aa9a7da9bc22 (diff)
downloadgo-git-c571526c06accbdc246312ed5c786339a049d6de.tar.gz
git: Added an example for Repository.Branches
-rw-r--r--example_test.go15
1 files changed, 15 insertions, 0 deletions
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)