| 42 | } |
| 43 | |
| 44 | func 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 | |
| 72 | func ExamplePlainClone_usernamePassword() { |
| 73 | // Tempdir to clone the repository |