()
| 17 | ) |
| 18 | |
| 19 | func 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 | |
| 44 | func ExamplePlainClone() { |
| 45 | // Tempdir to clone the repository |
nothing calls this directly
no test coverage detected
searching dependent graphs…