1all: build
 2
 3GIT_COMMIT:=$(shell git rev-list -1 HEAD)
 4GIT_LAST_TAG:=$(shell git describe --abbrev=0 --tags 2>/dev/null || true)
 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/git-bug/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
17.PHONY: build
18build:
19	go generate
20	go build -ldflags "$(LDFLAGS)" .
21
22# produce a build debugger friendly
23.PHONY: debug-build
24debug-build:
25	go generate
26	go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
27
28.PHONY: install
29install:
30	go generate
31	go install -ldflags "$(LDFLAGS)" .
32
33.PHONY: releases
34releases:
35	go generate
36	go run github.com/mitchellh/gox@v1.0.1 -ldflags "$(LDFLAGS)" -osarch '!darwin/386' -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
37
38secure: secure-practices secure-vulnerabilities
39
40.PHONY: secure-practices
41secure-practices:
42	go run github.com/praetorian-inc/gokart scan
43
44.PHONY: secure-vulnerabilities
45secure-vulnerabilities:
46	go run golang.org/x/vuln/cmd/govulncheck ./...
47
48.PHONY: test
49test:
50	go test -v -bench=. ./...
51
52.PHONY: pack-webui
53pack-webui:
54	npm run --prefix webui build
55	go run webui/pack_webui.go
56
57# produce a build that will fetch the web UI from the filesystem instead of from the binary
58.PHONY: debug-webui
59debug-webui:
60	go build -ldflags "$(LDFLAGS)" -tags=debugwebui
61
62.PHONY: clean-local-bugs
63clean-local-bugs:
64	git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
65	git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
66	rm -f .git/git-bug/bug-cache
67
68.PHONY: clean-remote-bugs
69clean-remote-bugs:
70	git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
71
72.PHONY: clean-local-identities
73clean-local-identities:
74	git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
75	git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
76	rm -f .git/git-bug/identity-cache
77
78.PHONY: clean-local-identities
79clean-remote-identities:
80	git ls-remote origin "refs/identities/*" | cut -f 2 | $(XARGS) git push origin -d