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)
 6COMMANDS_PATH:=github.com/MichaelMure/git-bug/commands
 7LDFLAGS:=-X ${COMMANDS_PATH}.GitCommit=${GIT_COMMIT} \
 8	-X ${COMMANDS_PATH}.GitLastTag=${GIT_LAST_TAG} \
 9	-X ${COMMANDS_PATH}.GitExactTag=${GIT_EXACT_TAG}
10
11build:
12	go generate
13	go build -ldflags "$(LDFLAGS)" .
14
15# produce a build debugger friendly
16debug-build:
17	go generate
18	go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
19
20install:
21	go generate
22	go install -ldflags "$(LDFLAGS)" .
23
24test:
25	go test -bench=. ./...
26
27pack-webui:
28	npm run --prefix webui build
29	go run webui/pack_webui.go
30
31# produce a build that will fetch the web UI from the filesystem instead of from the binary
32debug-webui:
33	go build -ldflags "$(LDFLAGS)" -tags=debugwebui
34
35clean-local-bugs:
36	git for-each-ref refs/bugs/ | cut -f 2 | xargs -r -n 1 git update-ref -d
37	git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | xargs -r -n 1 git update-ref -d
38	rm -f .git/git-bug/bug-cache
39
40clean-remote-bugs:
41	git ls-remote origin "refs/bugs/*" | cut -f 2 | xargs -r git push origin -d
42
43clean-local-identities:
44	git for-each-ref refs/identities/ | cut -f 2 | xargs -r -n 1 git update-ref -d
45	git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | xargs -r -n 1 git update-ref -d
46	rm -f .git/git-bug/identity-cache
47
48.PHONY: build install test pack-webui debug-webui clean-local-bugs clean-remote-bugs