tries to dump some info about a repo
This commit is contained in:
parent
7f8cdac6fa
commit
2c3babe917
5
Makefile
5
Makefile
|
@ -5,9 +5,10 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
|||
all: build
|
||||
|
||||
build: goimports
|
||||
GO111MODULE=off go build -v -x \
|
||||
PKG_CONFIG_PATH=/opt/libgit2/ GO111MODULE=off go build -v -x \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
./going2git -h
|
||||
ldd going2git
|
||||
./going2git --refs --repo .
|
||||
|
||||
vet:
|
||||
GO111MODULE=off go vet
|
||||
|
|
2
argv.go
2
argv.go
|
@ -11,7 +11,7 @@ import (
|
|||
var argv args
|
||||
|
||||
type args struct {
|
||||
Repo string `arg:"--repo" default:"./" help:"what .git repo to use?"`
|
||||
RepoPath string `arg:"--repo" default:"./" help:"path to the .git repo"`
|
||||
Hostname string `arg:"--hostname" help:"hostname to use"`
|
||||
Refs bool `arg:"--refs" help:"list the git ref hashes"`
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
// are sent via -ldflags at buildtime
|
||||
var VERSION string
|
||||
var BUILDTIME string
|
||||
|
||||
func main() {
|
||||
if argv.Refs {
|
||||
showRefs()
|
||||
} else {
|
||||
testMessage()
|
||||
}
|
||||
}
|
16
message.go
16
message.go
|
@ -7,22 +7,6 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// are sent via -ldflags at buildtime
|
||||
var VERSION string
|
||||
var BUILDTIME string
|
||||
|
||||
func main() {
|
||||
if argv.Refs {
|
||||
showRefs()
|
||||
} else {
|
||||
testMessage()
|
||||
}
|
||||
}
|
||||
|
||||
func showRefs() {
|
||||
log.Info("how do you do this with libgit2 and git2go? notsure.")
|
||||
}
|
||||
|
||||
func testMessage() {
|
||||
var input git.Trailer
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
git "go.wit.com/lib/libgit2"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func showRefs() error {
|
||||
log.Info("how do you do this with libgit2 and git2go? notsure.")
|
||||
repo, err := git.OpenRepository(argv.RepoPath)
|
||||
if err != nil {
|
||||
log.Info("open failed", argv.RepoPath, err)
|
||||
return err
|
||||
}
|
||||
ref, err := repo.Head()
|
||||
log.Info("head", ref, err, ref.Name())
|
||||
fmt.Printf("%+v\n", ref)
|
||||
walkRepo(repo)
|
||||
return nil
|
||||
}
|
||||
|
||||
func walkRepo(repo *git.Repository) {
|
||||
ri, err := repo.NewReferenceIterator()
|
||||
exitIf(err)
|
||||
|
||||
for {
|
||||
ref, err := ri.Next()
|
||||
if err != nil {
|
||||
log.Info("done", err)
|
||||
return
|
||||
}
|
||||
log.Info("head", ref, err, ref.Name(), ref.SymbolicTarget(), ref.Shorthand())
|
||||
// fmt.Printf("%+v\n", ref)
|
||||
// SymbolicTarget()
|
||||
}
|
||||
}
|
||||
|
||||
func exitIf(err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
log.Info("exit due to error", err)
|
||||
os.Exit(-1)
|
||||
}
|
Loading…
Reference in New Issue