Skip to content

Commit f505dec

Browse files
committed
meta: Metadata fixes: sorting, bug-fixes etc
1. The metadata version list was not sorted correctly, the usual `1.10` ordering issue; fix that with a version sort. * There are two implementations, I tested both on macOS via changing the `ifeq` guard to select (had a second `$(warning ...)` in for development to confirm branch selection). The `sed` one is based on the code in the `gimme` script, but reversed and adjusted for `Makefile` syntax. 2. Using `$(CUT) -b1-3` is no longer correct for prefix selection, now that we have `1.10` as 4 digits. 3. My making `GIMME_COPYRIGHT` a `readonly` variable in fd746b1 broke the `Makefile` rule for checking the two copyrights against each other; fix the `Makefile` to handle reality. 4. Committed the results of `make` fixing the sample files 5. I got a `CONTRIBUTORS` file with wildly different ordering; even after forcing on LC_COLLATE to a locally-valid name, there was no difference and $RandomGoogling suggest this is a known issue on macOS. So disable CONTRIBUTORS mangling on macOS. 6. Trying to make metadata on Linux I hit an issue because `fetch-object-urls` requires Python 3.6; which is fair, because 3.6 is an awesome release with many cool features which make it a compelling choice; but the script didn't guard against this and so bombed out later when trying to pass binary into the json module. 7. Updated CONTRIBUTORS on a Linux box Yaks shaved: 3.
1 parent 2937045 commit f505dec

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

.testdata/sample-binary-darwin

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# * the last formal release in all previous series
1010

1111
#
12+
1.10
1213
1.9.4
1314
1.8.7
1415
1.7.6
@@ -17,4 +18,3 @@
1718
1.4.3
1819
1.3.3
1920
1.2.2
20-
1.10

.testdata/sample-binary-linux

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# * the last formal release in all previous series
1010

1111
#
12+
1.10
1213
1.9.4
1314
1.8.7
1415
1.7.6
@@ -17,4 +18,3 @@
1718
1.4.3
1819
1.3.3
1920
1.2.2
20-
1.10

CONTRIBUTORS

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ gimme was built by these wonderful humans:
44
- Asato Wakisaka
55
- Ben Burkert
66
- Carmen Andoh
7+
- Cezar Sa Espinola
78
- Dan Buch
89
- Daniel Martí
910
- Dan Peterson
@@ -15,8 +16,10 @@ gimme was built by these wonderful humans:
1516
- Gemma Lynn
1617
- Geoff Levand
1718
- Hiro Asari
19+
- Hiroshi Ioka
1820
- Koichi Shiraishi
1921
- lupan2005
22+
- Matt Larraz
2023
- Mike Danese
2124
- Nathaniel Kofalt
2225
- Nathan Youngman

Makefile

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
SHELL := bash
22
UNAME := $(shell uname)
33
VERSION := $(shell git describe --always --tags)
4+
.DEFAULT_GOAL := all
5+
6+
# Affects sorting for CONTRIBUTORS file; unfortunately these are not
7+
# totally names (standards opaque IIRC) but this should work for us.
8+
LC_COLLATE:=en_US.UTF-8
9+
# Alas, macOS collation is broken and generates spurious differences.
410

511
AWK ?= awk
612
CAT ?= cat
@@ -21,6 +27,13 @@ ifeq ($(UNAME), Darwin)
2127
UNIQ := guniq
2228
endif
2329

30+
ifeq "$(shell $(SORT) --version-sort </dev/null >/dev/null 2>&1 || echo no)" "no"
31+
_ := $(warning "$(SORT) --version-sort not available, falling back to shell")
32+
REV_VERSION_SORT := $(SED) -E 's/\.([0-9](\.|$$))/.00\1/g; s/\.([0-9][0-9](\.|$$))/.0\1/g' | $(SORT) --general-numeric-sort -r | $(SED) 's/\.00*/./g'
33+
else
34+
REV_VERSION_SORT := $(SORT) --version-sort -r
35+
endif
36+
2437
SED_STRIP_COMMENTS ?= $(SED) -n -e '/^[^\#]/p'
2538

2639
KNOWN_BINARY_VERSIONS_FILES := \
@@ -35,7 +48,11 @@ all: lint CONTRIBUTORS assert-copyright $(KNOWN_BINARY_VERSIONS_FILES)
3548
.PHONY: clean
3649
clean:
3750
$(RM) $(KNOWN_BINARY_VERSIONS_FILES) .testdata/object-urls
51+
ifeq ($(UNAME), Darwin)
52+
$(warning Not deleting CONTRIBUTORS on macOS, locale sorting is broken)
53+
else
3854
$(RM) CONTRIBUTORS
55+
endif
3956

4057
.PHONY: lint
4158
lint:
@@ -46,7 +63,7 @@ lint:
4663
assert-copyright:
4764
@$(DIFF) -u \
4865
--label a/copyright/gimme \
49-
<($(AWK) 'BEGIN { FS="="; } /^GIMME_COPYRIGHT/ { gsub(/"/, "", $$2); print $$2 }' gimme) \
66+
<($(AWK) 'BEGIN { FS="="; } /^readonly GIMME_COPYRIGHT/ { gsub(/"/, "", $$2); print $$2 }' gimme) \
5067
--label b/copyright/LICENSE \
5168
<(awk '/^Copyright/ { print $$0 }' LICENSE)
5269

@@ -76,10 +93,13 @@ update-binary-versions: force-update-versions $(KNOWN_BINARY_VERSIONS_FILES)
7693
.testdata/sample-binary-%: .testdata/binary-%
7794
$(RM) $@
7895
$(CAT) .testdata/stubheader-sample > $@
79-
for prefix in $$($(SED_STRIP_COMMENTS) $< | $(GREP) -E '\.[0-9]+(\.|$$)' | $(CUT) -b1-3 | $(SORT) -r | $(UNIQ)) ; do \
80-
$(GREP) "^$${prefix}" $< | $(GREP) -vE 'rc|beta' | $(SORT) -r | $(HEAD) -1 >> $@ ; \
96+
for prefix in $$($(SED_STRIP_COMMENTS) $< | $(SED) -En 's/^([0-9]+\.[0-9]+)(\..*)?$$/\1/p' | $(REV_VERSION_SORT) | $(UNIQ)) ; do \
97+
$(GREP) "^$${prefix}" $< | $(GREP) -vE 'rc|beta' | $(REV_VERSION_SORT) | $(HEAD) -1 >> $@ ; \
8198
done
8299

83100
CONTRIBUTORS:
101+
ifeq ($(UNAME), Darwin)
102+
$(error macOS appears to have broken collation and will make spurious differences)
103+
endif
84104
@echo 'gimme was built by these wonderful humans:' >$@
85105
@$(GIT) log --format=%an | $(SORT) | $(UNIQ) | $(SED) 's/^/- /' >>$@

fetch-object-urls

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import json
44
import sys
55

6+
if sys.version_info < (3,6):
7+
raise Exception('Need at least Python 3.6 for this tool')
8+
# https://docs.python.org/3/whatsnew/3.6.html
9+
# > json.load() and json.loads() now support binary input.
10+
611
from urllib.request import urlopen
712
from urllib.parse import quote as urlquote
813

0 commit comments

Comments
 (0)