Skip to content

Commit 3baeea5

Browse files
committed
use git ls-remote to search the old branches to remove
git branch can't be used with these flags on the old version of git that comes with centos 7 Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent aef25be commit 3baeea5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

scripts/koji/koji_build.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ def is_old_branch(b):
6868

6969
def clean_old_branches(git_repo):
7070
with cd(git_repo):
71-
subprocess.check_call(['git', 'fetch'])
72-
remote_branches = (
73-
subprocess.check_output(['git', 'branch', '-rl', 'origin/koji/test/*/*']).decode().splitlines()
74-
)
75-
remote_branches = [b.strip()[len('origin/'):] for b in remote_branches]
71+
remote_branches = [
72+
line.split()[-1] for line in subprocess.check_output(['git', 'ls-remote']).decode().splitlines()
73+
]
74+
remote_branches = [b for b in remote_branches if b.startswith('refs/heads/koji/test/')]
7675
old_branches = [b for b in remote_branches if is_old_branch(b)]
7776
if old_branches:
7877
print("removing outdated remote branch(es)", flush=True)

0 commit comments

Comments
 (0)