Page MenuHomePhabricator

clean-starred-changes.py

Authored By
hashar
Jan 26 2024, 1:47 PM
Size
1 KB
Referenced Files
None
Subscribers
None

clean-starred-changes.py

#!/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

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14501824
Default Alt Text
clean-starred-changes.py (1 KB)

Event Timeline