Page MenuHomePhabricator
Paste P55739

clean-starred-changes.py
ActivePublic

Authored by hashar on Jan 26 2024, 1:47 PM.
Tags
None
Referenced Files
F41719661: clean-starred-changes.py
Jan 26 2024, 1:47 PM
Subscribers
None
#!/usr/bin/env python3
import subprocess
# replace with:
# git ls-remote ssh://gerrit.wikimedia.org:29418/All-Users.git refs/starred-changes/*/*/*
p = subprocess.run(
['git', 'for-each-ref',
'--format=%(objectname)%09%(refname)',
'refs/starred-changes/*/*/*',
],
check=True,
text=True,
capture_output=True,
)
known_for_deletion = set([
# `ignore` blob
'8485e986e458a566e6f6160f71d704edc10c57fc'
])
for line in p.stdout.rstrip().split("\n"):
# <blob sha> <refs/starred-changes/*/*/*>
(objectname, refname) = line.split("\t")
if objectname == 'ce7b81997cf51342dedaeccb071ce4ba3ed0cf52':
# We keep `star`
continue
if objectname in known_for_deletion:
print(f"git update-ref -d {refname}")
continue
p = subprocess.run(
['git', 'show', objectname],
check=True, text=True, capture_output=True
)
stars = p.stdout.rstrip().split("\n")
if 'star' in stars:
# convert it
print(f"git update-ref {refname} ce7b81997cf51342dedaeccb071ce4ba3ed0cf52")
continue
else:
known_for_deletion.add(objectname)
print(f"git update-ref -d {refname}")
continue