mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-14 19:10:11 +01:00
btlog: if git remote is specified, push commits to that remote
This makes fdroid automatically push the new binary transparency commits if there is a git_remote specified in either config.py or from a CLI arg.
This commit is contained in:
parent
40290fc5e0
commit
4b7084f779
@ -49,7 +49,8 @@ options = None
|
|||||||
|
|
||||||
def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
|
def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
|
||||||
url=None,
|
url=None,
|
||||||
commit_title='fdroid update'):
|
commit_title='fdroid update',
|
||||||
|
git_remote=None):
|
||||||
'''Log the indexes in a standalone git repo to serve as a "binary
|
'''Log the indexes in a standalone git repo to serve as a "binary
|
||||||
transparency" log.
|
transparency" log.
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
logging.info('Committing indexes to ' + btrepo)
|
||||||
if os.path.exists(os.path.join(btrepo, '.git')):
|
if os.path.exists(os.path.join(btrepo, '.git')):
|
||||||
gitrepo = git.Repo(btrepo)
|
gitrepo = git.Repo(btrepo)
|
||||||
else:
|
else:
|
||||||
@ -140,6 +142,17 @@ For more info on this idea:
|
|||||||
gitrepo.index.add([os.path.join(repodir, os.path.basename(f)), ])
|
gitrepo.index.add([os.path.join(repodir, os.path.basename(f)), ])
|
||||||
|
|
||||||
gitrepo.index.commit(commit_title)
|
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():
|
def main():
|
||||||
@ -153,7 +166,7 @@ def main():
|
|||||||
parser.add_argument("-u", "--url", default='https://f-droid.org',
|
parser.add_argument("-u", "--url", default='https://f-droid.org',
|
||||||
help="The base URL for the repo to log (default: https://f-droid.org)")
|
help="The base URL for the repo to log (default: https://f-droid.org)")
|
||||||
parser.add_argument("--git-remote", default=None,
|
parser.add_argument("--git-remote", default=None,
|
||||||
help="Create a repo signing key in a keystore")
|
help="Push the log to this git remote repository")
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
@ -213,7 +226,8 @@ def main():
|
|||||||
|
|
||||||
if new_files:
|
if new_files:
|
||||||
os.chdir(tempdirbase)
|
os.chdir(tempdirbase)
|
||||||
make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog')
|
make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog',
|
||||||
|
git_remote=options.git_remote)
|
||||||
shutil.rmtree(tempdirbase, ignore_errors=True)
|
shutil.rmtree(tempdirbase, ignore_errors=True)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -1409,7 +1409,7 @@ def main():
|
|||||||
index.make(apps, sortedids, archapks, repodirs[1], True)
|
index.make(apps, sortedids, archapks, repodirs[1], True)
|
||||||
|
|
||||||
if config.get('binary_transparency_remote'):
|
if config.get('binary_transparency_remote'):
|
||||||
btlog.make_binary_transparency_log(repodirs)
|
btlog.make_binary_transparency_log(repodirs, git_remote=config['binary_transparency_remote'])
|
||||||
|
|
||||||
if config['update_stats']:
|
if config['update_stats']:
|
||||||
# Update known apks info...
|
# Update known apks info...
|
||||||
|
Loading…
Reference in New Issue
Block a user