summaryrefslogtreecommitdiff
path: root/go-git/more.go
diff options
context:
space:
mode:
Diffstat (limited to 'go-git/more.go')
-rw-r--r--go-git/more.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/go-git/more.go b/go-git/more.go
new file mode 100644
index 0000000..b233948
--- /dev/null
+++ b/go-git/more.go
@@ -0,0 +1,35 @@
+package main
+
+import (
+ "os"
+
+ . "github.com/go-git/go-git/v5/_examples"
+)
+
+// Basic example of how to clone a repository using clone options.
+func more() {
+ CheckArgs("<url>", "<directory>")
+ url := os.Args[1]
+ directory := os.Args[2]
+
+ // Clone the given repository to the given directory
+ Info("git clone %s %s --recursive", url, directory)
+
+ /*
+ r, err := git.PlainClone(directory, false, &git.CloneOptions{
+ URL: url,
+ RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
+ })
+
+ CheckIfError(err)
+
+ // ... retrieving the branch being pointed by HEAD
+ ref, err := r.Head()
+ CheckIfError(err)
+ // ... retrieving the commit object
+ commit, err := r.CommitObject(ref.Hash())
+ CheckIfError(err)
+
+ fmt.Println(commit)
+ */
+}