mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
checkupdates: add --verbose progress to push_commits()
This commit is contained in:
parent
206f07364b
commit
66a340fe89
2 changed files with 42 additions and 1 deletions
|
|
@ -684,7 +684,7 @@ def get_last_build_from_app(app: metadata.App) -> metadata.Build:
|
||||||
return 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."""
|
"""Push commits using either appid or 'checkupdates' as branch name."""
|
||||||
git_repo = git.Repo.init('.')
|
git_repo = git.Repo.init('.')
|
||||||
files = set()
|
files = set()
|
||||||
|
|
@ -700,6 +700,20 @@ def push_commits(remote_name='origin'):
|
||||||
if m:
|
if m:
|
||||||
branch_name = m.group(1) # appid
|
branch_name = m.group(1) # appid
|
||||||
if len(files) > 0:
|
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)
|
git_repo.create_head(branch_name, force=True)
|
||||||
remote = git_repo.remotes[remote_name]
|
remote = git_repo.remotes[remote_name]
|
||||||
pushinfos = remote.push(
|
pushinfos = remote.push(
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,33 @@ class CheckupdatesTest(unittest.TestCase):
|
||||||
self.assertNotIn('checkupdates', git_repo.branches)
|
self.assertNotIn('checkupdates', git_repo.branches)
|
||||||
self.assertNotIn(appid, git_repo.remotes.upstream.refs)
|
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):
|
def test_prune_empty_appid_branches(self):
|
||||||
git_repo, origin_repo, upstream_repo = self._get_test_git_repos()
|
git_repo, origin_repo, upstream_repo = self._get_test_git_repos()
|
||||||
for remote in git_repo.remotes:
|
for remote in git_repo.remotes:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue