2022-10-24 12:02:33 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# an fdroid plugin for resetting app VCSs to the latest version for the metadata
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from fdroidserver import _, common, metadata
|
|
|
|
|
2022-11-22 20:46:56 +01:00
|
|
|
from fdroidserver.exception import VCSException
|
2022-10-24 12:02:33 +02:00
|
|
|
|
|
|
|
fdroid_summary = 'reset app VCSs to the latest version'
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2022-11-22 20:43:19 +01:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]"
|
|
|
|
)
|
2022-10-24 12:02:33 +02:00
|
|
|
common.setup_global_opts(parser)
|
2022-11-22 20:43:19 +01:00
|
|
|
parser.add_argument(
|
|
|
|
"appid",
|
|
|
|
nargs='*',
|
|
|
|
help=_("applicationId with optional versionCode in the form APPID[:VERCODE]"),
|
|
|
|
)
|
2022-10-24 12:02:33 +02:00
|
|
|
metadata.add_metadata_arguments(parser)
|
|
|
|
options = parser.parse_args()
|
|
|
|
common.options = options
|
|
|
|
pkgs = common.read_pkg_args(options.appid, True)
|
|
|
|
allapps = metadata.read_metadata(pkgs)
|
|
|
|
apps = common.read_app_args(options.appid, allapps, True)
|
|
|
|
common.read_config(options)
|
|
|
|
|
|
|
|
for appid, app in apps.items():
|
|
|
|
if "Builds" in app and len(app["Builds"]) > 0:
|
2022-11-24 20:50:39 +01:00
|
|
|
build = app.get('Builds')[-1]
|
2022-10-24 12:02:33 +02:00
|
|
|
logging.info(_("Cleaning up '{appid}' VCS").format(appid=appid))
|
|
|
|
try:
|
|
|
|
vcs, build_dir = common.setup_vcs(app)
|
2022-11-24 20:50:39 +01:00
|
|
|
vcs.gotorevision(build.commit)
|
|
|
|
if build.submodules:
|
|
|
|
vcs.initsubmodules()
|
2022-10-24 12:02:33 +02:00
|
|
|
|
|
|
|
except VCSException:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|