From 89175df12148ca7eb738e59a0d063ed9c579505b Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Sun, 18 Sep 2016 09:25:26 -0700 Subject: [PATCH] reorg repo, move library code to lib subdir, add glade --- .gitignore | 3 +- Makefile | 83 ++++++++++++++++---------------- glide.lock | 24 +++++++++ glide.yaml | 10 ++++ cli.go => lib/cli.go | 8 ++- commands.go => lib/commands.go | 0 templates.go => lib/templates.go | 0 util.go => lib/util.go | 0 main/main.go => main.go | 2 +- 9 files changed, 81 insertions(+), 49 deletions(-) create mode 100644 glide.lock create mode 100644 glide.yaml rename cli.go => lib/cli.go (99%) rename commands.go => lib/commands.go (100%) rename templates.go => lib/templates.go (100%) rename util.go => lib/util.go (100%) rename main/main.go => main.go (99%) diff --git a/.gitignore b/.gitignore index 8e56336..f46d2e1 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ t/issue.props t/.jira.d/templates dist/ src/ -t/.maven-cache \ No newline at end of file +t/.maven-cache +vendor/ \ No newline at end of file diff --git a/Makefile b/Makefile index 9ec730c..31f4405 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,12 @@ PLATFORMS= \ - freebsd-amd64 \ - linux-386 \ - linux-amd64 \ - windows-386 \ - windows-amd64 \ - darwin-amd64 \ + freebsd/amd64 \ + linux/386 \ + linux/amd64 \ + windows/386 \ + windows/amd64 \ + darwin/amd64 \ $(NULL) - # freebsd-386 \ - # freebsd-arm \ - # linux-arm \ - # openbsd-386 \ - # openbsd-amd64 \ - # darwin-386 - NAME=jira OS=$(shell uname -s) @@ -28,44 +21,50 @@ else BIN ?= $(GOBIN)$(SEP)$(NAME) endif -export GOPATH=$(CWD) +GOPATH ?= $(CWD) +export GOPATH DIST=$(CWD)$(SEP)dist GOBIN ?= $(CWD) CURVER ?= $(patsubst v%,%,$(shell [ -d .git ] && git describe --abbrev=0 --tags || grep ^\#\# CHANGELOG.md | awk '{print $$2; exit}')) -LDFLAGS:=-X jira.VERSION=$(CURVER) -w +LDFLAGS := -w -# use make DEBUG=1 and you can get a debuggable golang binary -# see https://github.com/mailgun/godebug +PACKAGE=github.com/Netflix-Skunkworks/go-jira + +# use 'make debug' and you can get a debuggable golang binary +# see https://golang.org/doc/gdb +# note on mac's you will need to codesign the gdb binary before you can use it: +# codesign -fs gdb-cert /usr/local/bin/gdb ifneq ($(DEBUG),) - GOBUILD=go get -v github.com/mailgun/godebug && ./bin/godebug build + GOBUILD=go build -ldflags "-s" -gcflags "-N -l" else - GOBUILD=go build -v -ldflags "$(LDFLAGS) -s" + GOBUILD=go build -ldflags "$(LDFLAGS) -s" endif -build: src/github.com/Netflix-Skunkworks/go-jira - $(GOBUILD) -o '$(BIN)' main/main.go +build: $(GOPATH)/src/$(PACKAGE) + cd $(GOPATH)/src/$(PACKAGE) && $(GOBUILD) -o $(BIN) main.go debug: - $(MAKE) DEBUG=1 + $(MAKE) DEBUG=1 build -src/%: +$(GOPATH)/src/%: mkdir -p $(@D) - test -L $@ || ln -sf '$(GOPATH)' $@ - go get -v $* $*/main + test -L $@ || ln -sf ../../.. $@ + glide install -v vet: - @go vet . - @go vet ./data - @go vet ./main + @go vet *.go lib/*.go data/*.go lint: @go get github.com/golang/lint/golint - @./bin/golint . - @./bin/golint ./data - @./bin/golint ./main + @$(GOPATH)/bin/golint . + @$(GOPATH)/bin/golint ./data + @$(GOPATH)/bin/golint ./lib + +test: $(GOPATH)/src/$(PACKAGE) + cd $(GOPATH)/src/$(SUBPACKAGE) && go test -v cross-setup: for p in $(PLATFORMS); do \ @@ -73,26 +72,24 @@ cross-setup: cd $(GOROOT)/src && sudo GOROOT_BOOTSTRAP=$(GOROOT) GOOS=$${p/-*/} GOARCH=$${p/*-/} bash ./make.bash --no-clean; \ done -all: - rm -rf $(DIST); \ - mkdir -p $(DIST); \ - for p in $(PLATFORMS); do \ - echo "Building for $$p"; \ - ${MAKE} build GOOS=$${p/-*/} GOARCH=$${p/*-/} BIN=$(DIST)/$(NAME)-$$p; \ - done - for x in $(DIST)/jira-windows-*; do mv $$x $$x.exe; done +all: $(GOPATH)/src/$(PACKAGE) + docker pull karalabe/xgo-latest + rm -rf dist + mkdir -p dist + docker run --rm -e EXT_GOPATH=/gopath -v $(GOPATH):/gopath -e TARGETS="$(PLATFORMS)" -v $$(pwd)/dist:/build karalabe/xgo-latest $(PACKAGE) + cd $(DIST) && for x in go-jira-*; do mv $$x $$(echo $$x | cut -c 4-); done fmt: - gofmt -s -w main/*.go *.go + gofmt -s -w main.go lib/*.go data/*.go install: - ${MAKE} GOBIN=$$HOME/bin build + ${MAKE} GOBIN=$(shell echo ~)/bin build NEWVER ?= $(shell echo $(CURVER) | awk -F. '{print $$1"."$$2"."$$3+1}') TODAY := $(shell date +%Y-%m-%d) changes: - @git log --pretty=format:"* %s [%cn] [%h]" --no-merges ^v$(CURVER) HEAD main/*.go *.go | grep -vE 'gofmt|go fmt' + @git log --pretty=format:"* %s [%cn] [%h]" --no-merges ^v$(CURVER) HEAD *.go lib/*.go data/*.go | grep -vE 'gofmt|go fmt' update-changelog: @echo "# Changelog" > CHANGELOG.md.new; \ @@ -105,6 +102,8 @@ update-changelog: tail -n +2 CHANGELOG.md >> CHANGELOG.md.new; \ mv CHANGELOG.md.new CHANGELOG.md; \ git commit -m "Updated Changelog" CHANGELOG.md; \ + perl -pi -e 's{VERSION = "$(CURVER)"}{VERSION = "$(NEWVER)"}' lib/cli.go; \ + git commit -m "version bump" lib/cli.go; \ git tag v$(NEWVER) version: diff --git a/glide.lock b/glide.lock new file mode 100644 index 0000000..4a7ee7d --- /dev/null +++ b/glide.lock @@ -0,0 +1,24 @@ +hash: a55cf7bdfb7f3de5ec4ae965d19857e8bdba595a3bcd4b02e5be0efe8223f7c5 +updated: 2016-09-18T00:35:57.456978105-07:00 +imports: +- name: github.com/coryb/optigo + version: 1b53172e5b4a00b528ea9fde88a4b76b596e293e +- name: github.com/howeyc/gopass + version: 3ca23474a7c7203e0a0a070fd33508f6efdb9b3d +- name: github.com/kballard/go-shellquote + version: d8ec1a69a250a17bb0e419c386eac1f3711dc142 +- name: github.com/mgutz/ansi + version: c286dcecd19ff979eeb73ea444e479b903f2cfcb +- name: golang.org/x/crypto + version: b13fc1fd382d01861b16b2e6474487d3d4d27f20 + subpackages: + - ssh/terminal +- name: golang.org/x/sys + version: a646d33e2ee3172a661fc09bca23bb4889a41bc8 + subpackages: + - unix +- name: gopkg.in/coryb/yaml.v2 + version: bd17d4d1209d8af092496a57db259d2d472676eb +- name: gopkg.in/op/go-logging.v1 + version: b2cb9fa56473e98db8caba80237377e83fe44db5 +testImports: [] diff --git a/glide.yaml b/glide.yaml new file mode 100644 index 0000000..a7892e5 --- /dev/null +++ b/glide.yaml @@ -0,0 +1,10 @@ +package: . +import: +- package: github.com/coryb/optigo + version: ^0.0.4 +- package: github.com/howeyc/gopass +- package: github.com/kballard/go-shellquote +- package: github.com/mgutz/ansi +- package: gopkg.in/coryb/yaml.v2 +- package: gopkg.in/op/go-logging.v1 + version: ^1.0.0 diff --git a/cli.go b/lib/cli.go similarity index 99% rename from cli.go rename to lib/cli.go index 827688c..2532d3f 100644 --- a/cli.go +++ b/lib/cli.go @@ -22,11 +22,9 @@ import ( "time" ) -var ( - log = logging.MustGetLogger("jira") - // VERSION is the go-jira library version - VERSION string -) +const VERSION = "0.1.7" + +var log = logging.MustGetLogger("jira") // Cli is go-jira client object type Cli struct { diff --git a/commands.go b/lib/commands.go similarity index 100% rename from commands.go rename to lib/commands.go diff --git a/templates.go b/lib/templates.go similarity index 100% rename from templates.go rename to lib/templates.go diff --git a/util.go b/lib/util.go similarity index 100% rename from util.go rename to lib/util.go diff --git a/main/main.go b/main.go similarity index 99% rename from main/main.go rename to main.go index 9cc2809..2b646dc 100644 --- a/main/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "bytes" "fmt" - "github.com/Netflix-Skunkworks/go-jira" + "github.com/Netflix-Skunkworks/go-jira/lib" "github.com/coryb/optigo" "gopkg.in/coryb/yaml.v2" "gopkg.in/op/go-logging.v1"