mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 23:10:29 +03:00
support pretty output in JSON and for binary transparency logs
This makes make_index_v1() support `fdroid update --pretty`, then also uses pretty output for the binary transparency logs, so that the git history has nice, readable diffs between commits.
This commit is contained in:
parent
c591a4cd89
commit
6f71465ec1
2 changed files with 16 additions and 2 deletions
|
|
@ -2364,6 +2364,8 @@ def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import git
|
import git
|
||||||
|
import xml.dom.minidom
|
||||||
|
|
||||||
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:
|
||||||
|
|
@ -2394,7 +2396,16 @@ def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
|
||||||
if not os.path.exists(repof):
|
if not os.path.exists(repof):
|
||||||
continue
|
continue
|
||||||
dest = os.path.join(cpdir, f)
|
dest = os.path.join(cpdir, f)
|
||||||
shutil.copyfile(repof, dest)
|
if f.endswith('.xml'):
|
||||||
|
doc = xml.dom.minidom.parse(repof)
|
||||||
|
output = doc.toprettyxml(encoding='utf-8')
|
||||||
|
with open(dest, 'wb') as f:
|
||||||
|
f.write(output)
|
||||||
|
elif f.endswith('.json'):
|
||||||
|
with open(repof) as fp:
|
||||||
|
output = json.load(fp, object_pairs_hook=collections.OrderedDict)
|
||||||
|
with open(dest, 'w') as fp:
|
||||||
|
json.dump(output, fp, indent=2)
|
||||||
gitrepo.index.add([repof, ])
|
gitrepo.index.add([repof, ])
|
||||||
for f in ('index.jar', 'index-v1.jar'):
|
for f in ('index.jar', 'index-v1.jar'):
|
||||||
repof = os.path.join(repodir, f)
|
repof = os.path.join(repodir, f)
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,9 @@ def make_v1(apps, packages, repodir, repodict, requestsdict):
|
||||||
json_name = 'index-v1.json'
|
json_name = 'index-v1.json'
|
||||||
index_file = os.path.join(repodir, json_name)
|
index_file = os.path.join(repodir, json_name)
|
||||||
with open(index_file, 'w') as fp:
|
with open(index_file, 'w') as fp:
|
||||||
|
if common.options.pretty:
|
||||||
|
json.dump(output, fp, default=_index_encoder_default, indent=2)
|
||||||
|
else:
|
||||||
json.dump(output, fp, default=_index_encoder_default)
|
json.dump(output, fp, default=_index_encoder_default)
|
||||||
|
|
||||||
if common.options.nosign:
|
if common.options.nosign:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue