Skip to content

Commit 2de5986

Browse files
committed
Preserve case-distinct compatibility blobs [v46-replacement-20261011]
1 parent 66682b4 commit 2de5986

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎tools/replace_v46.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ def replace(source, remote, revision):
6666
(data / 'replacement-audits').mkdir(exist_ok=True)
6767
(data / 'replacement-audits' / (OPERATION + '.json')).write_bytes(rules.encoded(audit))
6868
for checkout, message in [(legacy, 'Update v4 compatibility for one-time V46 replacement'), (data, 'Replace unpublished V46 once with audited old and new hashes')]:
69-
git(checkout, 'add', '--all'); git(checkout, 'commit', '-m', message)
69+
git(checkout, 'add', '--all')
70+
if checkout == legacy:
71+
# Preserve case-distinct legacy filenames on macOS as exact Git blobs.
72+
with zipfile.ZipFile(output / manifest['artifacts']['legacy']['path']) as archive:
73+
names = archive.namelist()
74+
for name in names:
75+
if sum(other.casefold() == name.casefold() for other in names) > 1:
76+
blob = subprocess.check_output(['git', '-C', str(legacy), 'hash-object', '-w', '--stdin'], input=archive.read(name)).decode().strip()
77+
git(legacy, 'update-index', '--add', '--cacheinfo', '100644,' + blob + ',' + name)
78+
git(checkout, 'commit', '-m', message)
7079
# Both branches advance together, or neither does. Ordinary FF rules reject races.
7180
git(data, 'push', '--atomic', 'origin', 'HEAD:refs/heads/rules-data', 'replacement-compat:refs/heads/v4')
7281
print('Atomically replaced V46 data and compatibility for ' + revision)

0 commit comments

Comments
 (0)