diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/clone/main.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/clone/main.go b/examples/clone/main.go index f95dc8f..0fa5fe6 100644 --- a/examples/clone/main.go +++ b/examples/clone/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "io" "os" "path/filepath" @@ -15,15 +16,15 @@ func main() { url := os.Args[1] directory := os.Args[2] - r := git.NewMemoryRepository() + r, err := git.NewFilesystemRepository(directory) + checkIfError(err) // Clone the given repository, using depth we create a shallow clone : // > git clone <url> --depth 1 color.Blue("git clone %s --depth 1 %s", url, directory) - err := r.Clone(&git.CloneOptions{ - URL: url, - Depth: 1, + err = r.Clone(&git.CloneOptions{ + URL: url, }) checkIfError(err) @@ -34,6 +35,9 @@ func main() { commit, err := r.Commit(ref.Hash()) checkIfError(err) + fmt.Println(commit) + os.Exit(0) + // ... we get all the files from the commit files, err := commit.Files() checkIfError(err) |