MCPcopy Create free account
hub / github.com/go-git/go-git / ExampleRepository_References

Function ExampleRepository_References

example_test.go:118–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116}
117
118func ExampleRepository_References() {
119 r, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
120 URL: "https://github.com/git-fixtures/basic.git",
121 })
122
123 // simulating a git show-ref
124 refs, _ := r.References()
125 refs.ForEach(func(ref *plumbing.Reference) error {
126 if ref.Type() == plumbing.HashReference {
127 fmt.Println(ref)
128 }
129
130 return nil
131 })
132
133 // Example Output:
134 // 6ecf0ef2c2dffb796033e5a02219af86ec6584e5 refs/remotes/origin/master
135 // e8d3ffab552895c19b9fcf7aa264d277cde33881 refs/remotes/origin/branch
136 // 6ecf0ef2c2dffb796033e5a02219af86ec6584e5 refs/heads/master
137
138}
139
140func ExampleRepository_CreateRemote() {
141 r, _ := git.Init(memory.NewStorage(), nil)

Callers

nothing calls this directly

Calls 4

NewStorageFunction · 0.92
ReferencesMethod · 0.80
ForEachMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected