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
30test:
31	go test -v -bench=. ./...
32
33pack-webui:
34	npm run --prefix webui build
35	go run webui/pack_webui.go
36
37# produce a build that will fetch the web UI from the filesystem instead of from the binary
38debug-webui:
39	go build -ldflags "$(LDFLAGS)" -tags=debugwebui
40
41clean-local-bugs:
42	git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
43	git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
44	rm -f .git/git-bug/bug-cache
45
46clean-remote-bugs:
47	git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
48
49clean-local-identities:
50	git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
51	git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
52	rm -f .git/git-bug/identity-cache
53
54.PHONY: build install test pack-webui debug-webui clean-local-bugs clean-remote-bugs