1all: build
2
3GIT_COMMIT:=$(shell git rev-list -1 HEAD)
4GIT_LAST_TAG:=$(shell git describe --abbrev=0 --tags)
5GIT_EXACT_TAG:=$(shell git name-rev --name-only --tags HEAD)
6UNAME_S := $(shell uname -s)
7XARGS:=xargs -r
8ifeq ($(UNAME_S),Darwin)
9 XARGS:=xargs
10endif
11
12COMMANDS_PATH:=github.com/MichaelMure/git-bug/commands
13LDFLAGS:=-X ${COMMANDS_PATH}.GitCommit=${GIT_COMMIT} \
14 -X ${COMMANDS_PATH}.GitLastTag=${GIT_LAST_TAG} \
15 -X ${COMMANDS_PATH}.GitExactTag=${GIT_EXACT_TAG}
16
17build:
18 go generate
19 go build -ldflags "$(LDFLAGS)" .
20
21# produce a build debugger friendly
22debug-build:
23 go generate
24 go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
25
26install:
27 go generate
28 go install -ldflags "$(LDFLAGS)" .
29
30releases:
31 go generate
32 gox -ldflags "$(LDFLAGS)" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
33
34test:
35 go test -v -bench=. ./...
36
37pack-webui:
38 npm run --prefix webui build
39 go run webui/pack_webui.go
40
41# produce a build that will fetch the web UI from the filesystem instead of from the binary
42debug-webui:
43 go build -ldflags "$(LDFLAGS)" -tags=debugwebui
44
45clean-local-bugs:
46 git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
47 git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
48 rm -f .git/git-bug/bug-cache
49
50clean-remote-bugs:
51 git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
52
53clean-local-identities:
54 git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
55 git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
56 rm -f .git/git-bug/identity-cache
57
58.PHONY: build install releases test pack-webui debug-webui clean-local-bugs clean-remote-bugs