MCPcopy
hub / github.com/go-git/go-git / ExampleClone

Function ExampleClone

example_test.go:19–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17)
18
19func ExampleClone() {
20 // Filesystem abstraction based on memory
21 fs := memfs.New()
22 // Git objects storer based on memory
23 storer := memory.NewStorage()
24
25 // Clones the repository into the worktree (fs) and stores all the .git
26 // content into the storer
27 _, err := git.Clone(storer, fs, &git.CloneOptions{
28 URL: "https://github.com/git-fixtures/basic.git",
29 })
30 if err != nil {
31 log.Fatal(err)
32 }
33
34 // Prints the content of the CHANGELOG file from the cloned repository
35 changelog, err := fs.Open("CHANGELOG")
36 if err != nil {
37 log.Fatal(err)
38 }
39
40 io.Copy(os.Stdout, changelog)
41 // Output: Initial changelog
42}
43
44func ExamplePlainClone() {
45 // Tempdir to clone the repository

Callers

nothing calls this directly

Calls 2

NewStorageFunction · 0.92
OpenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…