attempt to build an example

This commit is contained in:
Jeff Carr 2024-12-16 23:58:52 -06:00
parent fdd6d99107
commit c72040a9fb
3 changed files with 115 additions and 0 deletions

28
go-git/Makefile Normal file
View File

@ -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

52
go-git/main.go Normal file
View File

@ -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)
*/
}

35
go-git/more.go Normal file
View File

@ -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)
*/
}