summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go-git/Makefile28
-rw-r--r--go-git/main.go52
-rw-r--r--go-git/more.go35
3 files changed, 115 insertions, 0 deletions
diff --git a/go-git/Makefile b/go-git/Makefile
new file mode 100644
index 0000000..1e8c9f8
--- /dev/null
+++ b/go-git/Makefile
@@ -0,0 +1,28 @@
+VERSION = $(shell git describe --tags)
+GUIVERSION = $(shell git describe --tags)
+BUILDTIME = $(shell date +%s)
+
+all: build
+
+build: goimports
+ GO111MODULE=off go build \
+ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
+
+vet:
+ GO111MODULE=off go vet
+
+goimports:
+ goimports -w *.go
+ # // to globally reset paths:
+ # // gofmt -w -r '"go.wit.com/gui/gadgets" -> "go.wit.com/lib/gadgets"' *.go
+
+gocui: build
+ reset
+ ./go-clone-test --gui gocui
+
+install: goimports
+ GO111MODULE=off go install \
+ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
+
+force: build
+ ./go-clone-test --force
diff --git a/go-git/main.go b/go-git/main.go
new file mode 100644
index 0000000..79d1b71
--- /dev/null
+++ b/go-git/main.go
@@ -0,0 +1,52 @@
+package main
+
+import (
+ "os"
+
+ "github.com/go-git/go-git"
+)
+
+func main() {
+ /*
+ // Filesystem abstraction based on memory
+ fs := memfs.New()
+ // Git objects storer based on memory
+ storer := memory.NewStorage()
+ */
+
+ _, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
+ URL: "https://github.com/go-git/go-git",
+ Progress: os.Stdout,
+ })
+ /*
+ // Clones the repository into the worktree (fs) and stores all the .git
+ // content into the storer
+ _, err := git.Clone(storer, fs, &git.CloneOptions{
+ URL: "https://github.com/git-fixtures/basic.git",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ */
+
+ /*
+ // Prints the content of the CHANGELOG file from the cloned repository
+ changelog, err := fs.Open("CHANGELOG")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ io.Copy(os.Stdout, changelog)
+ */
+ /*
+ // Clone the given repository to the given directory
+ Info("git clone https://github.com/go-git/go-git")
+
+ _, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
+ URL: "https://github.com/go-git/go-git",
+ Progress: os.Stdout,
+ })
+
+ CheckIfError(err)
+ */
+}
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)
+ */
+}