ga-pwd: Don't output username by default + create `-H` and `-u` options
[sunny256-utils.git] / Makefile
blob6382bd881442fbb8fdfef0ae576b6abe8f82fd3e
1 # oyvholm/utils.git/Makefile
2 # File ID: 455af534-fd45-11dd-a4b7-000475e441b9
3 # Author: Øyvind A. Holm <sunny@sunbase.org>
5 T_GREEN=$$(tput setaf 2)
6 T_RESET=$$(tput sgr0)
8 .PHONY: all
9 all:
10 cd Lib && $(MAKE)
11 cd src && $(MAKE)
12 cd Git && $(MAKE)
14 .PHONY: clean
15 clean:
16 rm -f synced.sqlite.*.bck *.pyc
17 cd tests && $(MAKE) clean
18 cd Lib && $(MAKE) clean
19 cd src && $(MAKE) clean
20 cd Git && $(MAKE) clean
21 find . -name .testadd.tmp -type d -print0 | xargs -0r rm -rf
23 .PHONY: fullclean
24 fullclean:
25 $(MAKE) clean
26 cd src && $(MAKE) fullclean
27 cd Git && $(MAKE) fullclean
29 .PHONY: lgd
30 lgd:
31 git lg --date-order $$(git branch -a | cut -c3- | \
32 grep -Ee 'remotes/(Spread|bitbucket|repoorcz|sunbase)/' | \
33 grep -v 'HEAD -> ') $$(git branch | cut -c3-)
35 .PHONY: obsolete
36 obsolete:
37 git delrembr $$(cat Div/obsolete-refs.txt); true
39 .PHONY: push
40 push:
41 $(MAKE) push-to-gitlab
42 git pa
44 .PHONY: push-to-gitlab
45 push-to-gitlab:
46 git branch | grep 'tmp-gitlab' && exit 1 || true
47 git fetch gitlab
48 for rev in $$(git sht --reverse gitlab/master..master); do \
49 echo; \
50 GIT_PAGER=cat \
51 git log -1 --format="$(T_GREEN)%h$(T_RESET) %s" $$rev \
52 && echo git branch tmp-gitlab $$rev \
53 && git branch tmp-gitlab $$rev \
54 && echo git branch synced/tmp-gitlab $$rev \
55 && git branch synced/tmp-gitlab $$rev \
56 && echo git push gitlab \
57 tmp-gitlab:master synced/tmp-gitlab:synced/master \
58 && git push gitlab \
59 tmp-gitlab:master synced/tmp-gitlab:synced/master \
60 && echo git branch -D tmp-gitlab synced/tmp-gitlab \
61 && git branch -D tmp-gitlab synced/tmp-gitlab \
62 && if git sht gitlab/master..master | grep -q ^; then \
63 printf '%s sleep 60...' $$(date +%H:%M:%S); \
64 sleep 60; \
65 echo ok; \
66 fi \
67 || exit 1; \
68 done
69 git pa -s
70 git push gitlab
72 .PHONY: remotes
73 remotes:
74 git remote add \
75 sunbase sunny@git.sunbase.org:/home/sunny/Git/utils.git; true
76 git remote add bitbucket git@bitbucket.org:sunny256/utils.git; true
77 git remote add gitlab git@gitlab.com:oyvholm/utils.git; true
78 git remote add \
79 repoorcz ssh://sunny256@repo.or.cz/srv/git/sunny256-utils.git; true
81 .PHONY: test
82 test:
83 test ! -e synced.sql.lock
84 # FIXME: synced.sql is modified in Gitlab CI, disable it for now
85 if test "$(GITLAB_CI)" != "true"; then \
86 test -z "$$(filesynced --valid-sha 2>&1)"; \
88 test "$$(git log | grep -- -by: | sort -u | wc -l)" = "2"
89 cd tests && $(MAKE) test
90 cd Lib && $(MAKE) test
91 cd src && $(MAKE) test
92 cd Git && $(MAKE) test
94 .PHONY: test-clean
95 test-clean:
96 $(MAKE) fullclean
97 git status --porcelain --ignored | grep ^ && exit 1 || true
99 .PHONY: testport
100 testport:
101 cd tests && $(MAKE) testport
102 cd Lib && $(MAKE) testport
103 cd src && $(MAKE) testport
104 cd Git && $(MAKE) testport
106 .PHONY: unmerged
107 unmerged:
108 git log --graph --date-order --format=fuller -p --decorate=short \
109 $$(git br -a --contains firstrev --no-merged | git nocom) \
110 ^master
112 .PHONY: update-synced
113 update-synced:
114 test ! -e .update-synced_token.tmp
115 test ! -e synced.sql.lock
116 filesynced --lock >.update-synced_token.tmp
117 git ls-files | while read f; do \
118 if test -f "$$f" -a ! -h "$$f" ; then \
119 echo "INSERT INTO synced (file) VALUES ('$$f');"; \
120 fi; \
121 done | sqlite3 synced.sqlite 2>/dev/null || true
122 echo "SELECT file FROM synced ORDER BY file;" | \
123 sqlite3 synced.sqlite | while read f; do \
124 if test ! -f "$$f"; then \
125 echo "DELETE FROM synced WHERE file = '$$f';"; \
126 echo "DELETE FROM todo WHERE file = '$$f';"; \
127 fi; \
128 done | sqlite3 synced.sqlite
129 filesynced --unlock $$(cat .update-synced_token.tmp)
130 rm -f .update-synced_token.tmp
132 .PHONY: valgrind
133 valgrind:
134 cd Git && $(MAKE) valgrind