Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P55739
clean-starred-changes.py
Active
Public
Actions
Authored by
hashar
on Jan 26 2024, 1:47 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F41719661: clean-starred-changes.py
Jan 26 2024, 1:47 PM
2024-01-26 13:47:31 (UTC+0)
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
Event Timeline
hashar
created this paste.
Jan 26 2024, 1:47 PM
2024-01-26 13:47:30 (UTC+0)
hashar
mentioned this in
T355794: Cleanup unused refs in All-Users under refs/starred-changes/xx/yyyyxx/zz
.
Jan 26 2024, 1:51 PM
2024-01-26 13:51:29 (UTC+0)
Log In to Comment