mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-11 17:50:29 +03:00
checkupdates: remove appid branches that have been merged
To avoid having thousands of branches on checkupdatess-bot's remote, this cleans up any remote branches that are pointing to commit that has been fully merged.
This commit is contained in:
parent
78b368f88b
commit
206f07364b
2 changed files with 52 additions and 6 deletions
|
|
@ -724,6 +724,27 @@ def push_commits(remote_name='origin'):
|
|||
logging.debug(remote.url + ': ' + pushinfo.summary)
|
||||
|
||||
|
||||
def prune_empty_appid_branches(git_repo=None):
|
||||
"""Remove empty branches from checkupdates-bot git remote."""
|
||||
if git_repo is None:
|
||||
git_repo = git.Repo.init('.')
|
||||
main_branch = 'main'
|
||||
if main_branch not in git_repo.remotes.upstream.refs:
|
||||
main_branch = 'master'
|
||||
upstream_main = 'upstream/' + main_branch
|
||||
|
||||
remote = git_repo.remotes.origin
|
||||
remote.update(prune=True)
|
||||
merged_branches = git_repo.git().branch(remotes=True, merged=upstream_main).split()
|
||||
for remote_branch in merged_branches:
|
||||
if not remote_branch or '/' not in remote_branch:
|
||||
continue
|
||||
if remote_branch.split('/')[1] not in (main_branch, 'HEAD'):
|
||||
for ref in git_repo.remotes.origin.refs:
|
||||
if remote_branch == ref.name:
|
||||
remote.push(':%s' % ref.remote_head, force=True) # rm remote branch
|
||||
|
||||
|
||||
def status_update_json(processed: list, failed: dict) -> None:
|
||||
"""Output a JSON file with metadata about this run."""
|
||||
logging.debug(_('Outputting JSON'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue