1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-04 16:30:12 +02:00

refactor App.get_last_build() to checkupdates

This function is only used in checkupdates, and removing it from the App
class moves the App class one step closer to being a plain dict, which is a
more Pythonic style.
This commit is contained in:
Hans-Christoph Steiner 2023-05-02 10:57:35 +02:00
parent 8300ed051b
commit 74dddfd9fb
2 changed files with 11 additions and 13 deletions

View File

@ -110,7 +110,7 @@ def check_tags(app, pattern):
vcs.gotorevision(None)
last_build = app.get_last_build()
last_build = get_last_build_from_app(app)
try_init_submodules(app, last_build, vcs)
@ -252,10 +252,7 @@ def check_repomanifest(app, branch=None):
elif repotype == 'bzr':
vcs.gotorevision(None)
last_build = metadata.Build()
if app.get('Builds', []):
last_build = app.get('Builds', [])[-1]
last_build = get_last_build_from_app(app)
try_init_submodules(app, last_build, vcs)
hpak = None
@ -364,7 +361,7 @@ def possible_subdirs(app):
else:
build_dir = Path('build') / app.id
last_build = app.get_last_build()
last_build = get_last_build_from_app(app)
for d in dirs_with_manifest(build_dir):
m_paths = common.manifest_paths(d, last_build.gradle)
@ -399,7 +396,7 @@ def fetch_autoname(app, tag):
except VCSException:
return None
last_build = app.get_last_build()
last_build = get_last_build_from_app(app)
logging.debug("...fetch auto name from " + str(build_dir))
new_name = None
@ -579,6 +576,13 @@ def checkupdates_app(app):
raise FDroidException("Git commit failed")
def get_last_build_from_app(app):
if app.get('Builds'):
return app['Builds'][-1]
else:
return metadata.Build()
def status_update_json(processed, failed):
"""Output a JSON file with metadata about this run."""
logging.debug(_('Outputting JSON'))

View File

@ -174,12 +174,6 @@ class App(dict):
else:
raise AttributeError("No such attribute: " + name)
def get_last_build(self):
if len(self.Builds) > 0:
return self.Builds[-1]
else:
return Build()
TYPE_STRING = 2
TYPE_BOOL = 3