server: git push for binary transparency in fdroid server update

Since `fdroid server update` is the place where all uploads to servers
happens, it makes sense to also handle the git push for the binary
transparency log here instead of `fdroid btlog`
This commit is contained in:
Hans-Christoph Steiner 2017-04-10 20:28:43 +02:00
parent e3152e9ef0
commit 299ba86948
4 changed files with 22 additions and 30 deletions

View file

@ -42,6 +42,7 @@ import zipfile
from argparse import ArgumentParser
from . import common
from . import server
options = None
@ -49,8 +50,7 @@ options = None
def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
url=None,
commit_title='fdroid update',
git_remote=None):
commit_title='fdroid update'):
'''Log the indexes in a standalone git repo to serve as a "binary
transparency" log.
@ -142,17 +142,6 @@ For more info on this idea:
gitrepo.index.add([os.path.join(repodir, os.path.basename(f)), ])
gitrepo.index.commit(commit_title)
if git_remote:
logging.info('Pushing binary transparency log to ' + git_remote)
origin = git.remote.Remote(gitrepo, 'origin')
if origin in gitrepo.remotes:
origin = gitrepo.remote('origin')
if 'set_url' in dir(origin): # added in GitPython 2.x
origin.set_url(git_remote)
else:
origin = gitrepo.create_remote('origin', git_remote)
origin.fetch()
origin.push('master')
def main():
@ -227,8 +216,9 @@ def main():
if new_files:
os.chdir(tempdirbase)
make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog',
git_remote=options.git_remote)
make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog')
if options.git_remote:
server.push_binary_transparency(options.git_repo, options.git_remote)
shutil.rmtree(tempdirbase, ignore_errors=True)
if __name__ == "__main__":