Skip to content

Commit 5d0c3e1

Browse files
committed
A faster way to get modification dates
1 parent f974b2f commit 5d0c3e1

File tree

2 files changed

+57
-15
lines changed

2 files changed

+57
-15
lines changed

Makefile

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,32 +106,36 @@ meta-data/section.data: meta-data/annex-f meta-data/networking-section.data bin/
106106

107107
dates: meta-data/dates
108108

109-
# Generate file with issue number and unix timestamp of last change.
110-
meta-data/dates: xml/issue[0-9]*.xml
111-
for i in xml/issue[0-9]*.xml ; do \
112-
n="$${i#xml/issue}" ; n="$${n%.xml}" ; \
113-
grep -s -q "^$$n " $@ && test $$i -ot $@ && continue ; \
114-
echo $$i >&2 ; \
115-
git log -1 --pretty="format:$$n %ct%n" $$i ; \
116-
done > $@.new
117-
cat $@ $@.new | sort -n -r | sort -n -k 1 -u > $@.tmp
118-
rm $@.new
119-
$(call update,$@)
109+
optcmd = $(shell command -v $(1) || echo :)
120110

111+
# Generate file with issue number and unix timestamp of last change.
112+
python := $(call optcmd,python)
113+
meta-data/dates: xml/issue[0-9]*.xml bin/make_dates.py
114+
if [ "$(python)" = ":" ]; then \
115+
for i in xml/issue[0-9]*.xml ; do \
116+
n="$${i#xml/issue}" ; n="$${n%.xml}" ; \
117+
grep -s -q "^$$n " $@ && test $$i -ot $@ && continue ; \
118+
echo $$i >&2 ; \
119+
git log -1 --pretty="format:$$n %ct%n" $$i ; \
120+
done > $@.new; \
121+
cat $@ $@.new | sort -n -r | sort -n -k 1 -u > $@.tmp; \
122+
rm $@.new; \
123+
$(call update,$@); \
124+
else \
125+
git whatchanged --no-show-signature --pretty=%ct | $(python) bin/make_dates.py > $@; \
126+
fi
121127

122128
new-papers:
123129
rm -f meta-data/index.json meta-data/paper_titles.txt
124130
$(MAKE) meta-data/paper_titles.txt
125131

126-
optcmd = $(shell command -v $(1) || echo :)
127-
128-
# If python is not installed then create an empty meta-data/paper_titles.txt
132+
# If curl is not installed then create an empty meta-data/paper_titles.txt
129133
meta-data/index.json:
130134
$(call optcmd,curl) https://wg21.link/index.json > $@
131135

132136
# If python is not installed then create an empty meta-data/paper_titles.txt
133137
meta-data/paper_titles.txt: | meta-data/index.json
134-
$(call optcmd,python) bin/make_paper_titles.py $| > $@
138+
$(python) bin/make_paper_titles.py $| > $@
135139

136140
.PRECIOUS: meta-data/dates
137141
.PRECIOUS: meta-data/paper_titles.txt

bin/make_dates.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/python
2+
3+
# usage: git whatchanged --no-show-signature --pretty=%ct | python bin/make_dates.py > dates
4+
5+
import sys
6+
import re
7+
8+
# The input looks like
9+
# 1728481670
10+
#
11+
# :100644 100644 02412851ac 9f5998ba82 M xml/issue4159.xml
12+
# :100644 100644 fa2274aa17 74485b30c1 M xml/issue4162.xml
13+
# :100644 100644 8023699cb9 d007f71c08 M xml/issue4164.xml
14+
15+
mtimes = {}
16+
current_mtime = ''
17+
for l in sys.stdin.readlines():
18+
l = l.rstrip()
19+
if not l:
20+
# blank line
21+
continue
22+
23+
# timestamp
24+
if l[0] != ':':
25+
current_mtime = l
26+
continue
27+
28+
# last piece of line is the file name
29+
file = l.split()[-1]
30+
m = re.match('xml/issue(\\d+).xml', file)
31+
32+
if m:
33+
num = int(m[1])
34+
if num not in mtimes:
35+
mtimes[num] = current_mtime
36+
37+
for (num, time) in sorted(list(mtimes.items())):
38+
print(f'{num:04} {time}')

0 commit comments

Comments
 (0)