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

Function ExamplePlainClone

example_test.go:44–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44func ExamplePlainClone() {
45 // Tempdir to clone the repository
46 dir, err := os.MkdirTemp("", "clone-example")
47 if err != nil {
48 log.Fatal(err)
49 }
50
51 defer os.RemoveAll(dir) // clean up
52
53 // Clones the repository into the given dir, just as a normal git clone does
54 _, err = git.PlainClone(dir, false, &git.CloneOptions{
55 URL: "https://github.com/git-fixtures/basic.git",
56 })
57
58 if err != nil {
59 log.Fatal(err)
60 }
61
62 // Prints the content of the CHANGELOG file from the cloned repository
63 changelog, err := os.Open(filepath.Join(dir, "CHANGELOG"))
64 if err != nil {
65 log.Fatal(err)
66 }
67
68 io.Copy(os.Stdout, changelog)
69 // Output: Initial changelog
70}
71
72func ExamplePlainClone_usernamePassword() {
73 // Tempdir to clone the repository

Callers

nothing calls this directly

Calls 2

JoinMethod · 0.80
OpenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…