1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-14 19:10:11 +01:00

checkupdates: add --verbose progress to push_commits()

This commit is contained in:
Hans-Christoph Steiner 2022-06-28 17:31:40 +02:00 committed by linsui
parent 206f07364b
commit 66a340fe89
2 changed files with 42 additions and 1 deletions

View File

@ -684,7 +684,7 @@ def get_last_build_from_app(app: metadata.App) -> metadata.Build:
return metadata.Build()
def push_commits(remote_name='origin'):
def push_commits(remote_name='origin', verbose=False):
"""Push commits using either appid or 'checkupdates' as branch name."""
git_repo = git.Repo.init('.')
files = set()
@ -700,6 +700,20 @@ def push_commits(remote_name='origin'):
if m:
branch_name = m.group(1) # appid
if len(files) > 0:
if verbose:
from clint.textui import progress
bar = progress.Bar()
class MyProgressPrinter(git.RemoteProgress):
def update(self, op_code, current, maximum=None, message=None):
if isinstance(maximum, float):
bar.show(current, maximum)
progress = MyProgressPrinter()
else:
progress = None
git_repo.create_head(branch_name, force=True)
remote = git_repo.remotes[remote_name]
pushinfos = remote.push(

View File

@ -379,6 +379,33 @@ class CheckupdatesTest(unittest.TestCase):
self.assertNotIn('checkupdates', git_repo.branches)
self.assertNotIn(appid, git_repo.remotes.upstream.refs)
def test_push_commits_verbose(self):
class Options:
verbose = True
fdroidserver.checkupdates.options = Options
repos = self._get_test_git_repos()
git_repo = repos[0]
git_repo.remotes.origin.push(git_repo.active_branch)
git_repo.remotes.upstream.push(git_repo.active_branch)
# make commit
appid = 'org.adaway'
app = fdroidserver.metadata.read_metadata({appid: -1})[appid]
build = fdroidserver.metadata.Build()
build.versionName = 'fake'
build.versionCode = 999999999
app.Builds.append(build)
metadata_file = 'metadata/%s.yml' % appid
fdroidserver.metadata.write_metadata(metadata_file, app)
git_repo.index.add(metadata_file)
git_repo.index.commit('changed ' + appid)
# and push the new commit to the dynamic branch
fdroidserver.checkupdates.push_commits()
self.assertIn(appid, git_repo.branches)
self.assertIn(appid, git_repo.remotes.origin.refs)
def test_prune_empty_appid_branches(self):
git_repo, origin_repo, upstream_repo = self._get_test_git_repos()
for remote in git_repo.remotes: