Skip to content

Commit b949b5b

Browse files
authored
Merge pull request #2 from github/go-getify
Make `git-sizer` installable using `go get`
2 parents 6aa9318 + 27585c8 commit b949b5b

File tree

14 files changed

+18
-19
lines changed

14 files changed

+18
-19
lines changed
File renamed without changes.
File renamed without changes.

Makefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,43 @@ export GOPATH
66
GO := $(CURDIR)/script/go
77
GOFMT := $(CURDIR)/script/gofmt
88

9-
BIN := bin
10-
119
GOFLAGS := \
1210
--tags "static" \
1311
-ldflags "-X main.BuildVersion=$(shell git rev-parse HEAD) -X main.BuildDescribe=$(shell git describe --tags --always --dirty)"
14-
GO_CMDS := $(BIN)/git-sizer
15-
GO_PKGS := $(shell cd .gopath/src && find github.com/github/git-sizer/ -type f -name '*.go' | xargs -n1 dirname | grep -v '^github.com/github/git-sizer/vendor/' | sort -u)
16-
GO_SRCS := $(shell find src -type f -name '*.go')
1712

18-
.PHONY: all
19-
all: $(GO_CMDS)
13+
GO_SRCS := $(shell cd $(GOPATH)/src/$(PACKAGE) && $(GO) list -f '{{$$ip := .ImportPath}}{{range .GoFiles}}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}}{{range .CgoFiles}}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}}{{range .TestGoFiles}}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}}{{range .XTestGoFiles}}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}}' ./...)
2014

21-
$(BIN)/%: $(GO_SRCS) | $(BIN)
22-
$(GO) build $(GOFLAGS) -o $@ $(PACKAGE)/$*
15+
.PHONY: all
16+
all: bin/git-sizer
2317

24-
$(BIN):
25-
mkdir -p $(BIN)
18+
.PHONY: bin/git-sizer
19+
bin/git-sizer:
20+
mkdir -p bin
21+
$(GO) build $(GOFLAGS) -o $@ $(PACKAGE)
2622

2723
.PHONY: test
28-
test: $(GO_CMDS) gotest
24+
test: bin/git-sizer gotest
2925

3026
.PHONY: gotest
3127
gotest:
32-
$(GO) test -timeout 60s $(GOFLAGS) $(GO_PKGS)
28+
$(GO) test -timeout 60s $(GOFLAGS) ./...
3329

3430
.PHONY: gofmt
3531
gofmt:
36-
find src test -name "*.go" -print0 | xargs -0 $(GOFMT) -l -w | sed -e 's/^/Fixing /'
32+
$(GOFMT) -l -w $(GO_SRCS) | sed -e 's/^/Fixing /'
3733

3834
.PHONY: goimports
3935
goimports:
40-
find src -name "*.go" -print0 | xargs -0 goimports -l -w -e
36+
goimports -l -w -e $(GO_SRCS)
4137

4238
.PHONY: govet
4339
govet:
44-
$(GO) vet $(GO_PKGS)
40+
$(GO) vet ./...
4541

4642
.PHONY: clean
4743
clean:
4844
rm -rf bin
45+
46+
.PHONY: srcs
47+
srcs:
48+
@printf "%s\n" $(GO_SRCS)
File renamed without changes.

src/git-sizer/git_sizer_test.go renamed to git_sizer_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import (
77

88
// Smoke test that the program runs.
99
func TestExec(t *testing.T) {
10-
command := exec.Command("bin/git-sizer", ".")
11-
command.Dir = "../.."
10+
command := exec.Command("bin/git-sizer")
1211
output, err := command.CombinedOutput()
1312
if err != nil {
1413
t.Errorf("command failed (%s); output: %#v", err, string(output))
File renamed without changes.
File renamed without changes.

script/bootstrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ fi
1515
BASE="$GOPATH/src/github.com/github/git-sizer"
1616
rm -f "$BASE"
1717
mkdir -p $(dirname "$BASE")
18-
ln -s "$(pwd)/src" "$BASE"
18+
ln -s "$(pwd)" "$BASE"
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)