1all: build
2
3GIT_COMMIT:=$(shell git rev-list -1 HEAD)
4GIT_LAST_TAG:=$(shell git describe --dirty --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
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# TODO: change pinned version of GoKart to "latest" once PR #84 is merged
43# https://github.com/praetorian-inc/gokart/pull/84
44# go install github.com/praetorian-inc/gokart@latest
45 go install github.com/selesy/gokart-pre
46 gokart scan
47
48.PHONY: secure-vulnerabilities
49secure-vulnerabilities:
50 go install golang.org/x/vuln/cmd/govulncheck
51 govulncheck ./...
52
53.PHONY: test
54test:
55 go test -v -bench=. ./...
56
57.PHONY: pack-webui
58pack-webui:
59 npm run --prefix webui build
60 go run webui/pack_webui.go
61
62# produce a build that will fetch the web UI from the filesystem instead of from the binary
63.PHONY: debug-webui
64debug-webui:
65 go build -ldflags "$(LDFLAGS)" -tags=debugwebui
66
67.PHONY: clean-local-bugs
68clean-local-bugs:
69 git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
70 git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
71 rm -f .git/git-bug/bug-cache
72
73.PHONY: clean-remote-bugs
74clean-remote-bugs:
75 git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
76
77.PHONY: clean-local-identities
78clean-local-identities:
79 git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
80 git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
81 rm -f .git/git-bug/identity-cache
82
83.PHONY: clean-local-identities
84clean-remote-identities:
85 git ls-remote origin "refs/identities/*" | cut -f 2 | $(XARGS) git push origin -d