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
34secure: secure-practices secure-vulnerabilities
35
36secure-practices:
37 go install github.com/praetorian-inc/gokart
38 gokart scan
39
40secure-vulnerabilities:
41 go install golang.org/x/vuln/cmd/govulncheck@latest
42 govulncheck ./...
43
44test:
45 go test -v -bench=. ./...
46
47pack-webui:
48 npm run --prefix webui build
49 go run webui/pack_webui.go
50
51# produce a build that will fetch the web UI from the filesystem instead of from the binary
52debug-webui:
53 go build -ldflags "$(LDFLAGS)" -tags=debugwebui
54
55clean-local-bugs:
56 git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
57 git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
58 rm -f .git/git-bug/bug-cache
59
60clean-remote-bugs:
61 git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
62
63clean-local-identities:
64 git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
65 git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
66 rm -f .git/git-bug/identity-cache
67
68clean-remote-identities:
69 git ls-remote origin "refs/identities/*" | cut -f 2 | $(XARGS) git push origin -d
70
71.PHONY: build install releases test pack-webui debug-webui clean-local-bugs clean-remote-bugs
72.PHONY: secure secure-vulnerabilities secure-practice