diff options
| -rw-r--r-- | .gitignore | 7 | ||||
| -rw-r--r-- | Makefile | 22 | ||||
| -rw-r--r-- | argv.go | 33 | ||||
| -rw-r--r-- | message.go | 27 |
4 files changed, 89 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9314288 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.swp +go.mod +go.sum +/files/* +/work/* + +going2git diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4cc1786 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +VERSION = $(shell git describe --tags) +GUIVERSION = $(shell git describe --tags) +BUILDTIME = $(shell date +%s) + +all: build + +build: goimports + GO111MODULE=off go build -v -x \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + ./going2git -h + +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 + +install: goimports + GO111MODULE=off go install \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" @@ -0,0 +1,33 @@ +package main + +/* + this parses the command line arguements +*/ + +import ( + "go.wit.com/dev/alexflint/arg" +) + +var argv args + +type args struct { + Repo string `arg:"--repo" default:"/etc/gowebd/repomap" help:"what .git repo to use?"` + Hostname string `arg:"--hostname" default:"go.wit.com" help:"hostname to use"` +} + +func (args) Version() string { + return "going2git " + VERSION + " Built on " + BUILDTIME +} + +func init() { + arg.MustParse(&argv) +} + +func (a args) Description() string { + return ` +This is a demo of git2go to show how it works. + +Actually, I don't know how to use libgit2 or git2go yet so really this is just +an example of how to compile something against it. +` +} diff --git a/message.go b/message.go new file mode 100644 index 0000000..35a2e22 --- /dev/null +++ b/message.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + + git "go.wit.com/lib/libgit2" + "go.wit.com/log" +) + +// are sent via -ldflags at buildtime +var VERSION string +var BUILDTIME string + +func main() { + var input git.Trailer + + input.Key = "Co-authored-by" + input.Value = "Alice <[email protected]>" + /* + git2go.Trailer + git2go.Trailer{Key: "Signed-off-by", Value: "Bob <[email protected]>"}} + */ + + fmt.Printf("%s", input) + actual, err := git.MessageTrailers(input.Key) + log.Info("actual", actual, err) +} |
