Allow selecting different algorithms.

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2020-02-11 15:14:06 +01:00
parent f3a6b55ee0
commit e7066a3e13

View file

@ -22,6 +22,13 @@ def get_cli_arguments(args):
help="The base URL of the Koji hub",
default="https://koji.fedoraproject.org/kojihub",
)
parser.add_argument(
"--algorithm",
"--algo",
help="The algorithm with which to determine the next release",
choices=["sequential_builds", "holistic_heuristic"],
default="sequential_builds",
)
parser.add_argument("package", help="The name of the package of interest")
parser.add_argument("dist", help="The dist-tag of interest")
@ -44,16 +51,7 @@ def parse_release_tag(tag):
return pkgrel, middle, minorbump
def main(args):
""" Main method. """
args = get_cli_arguments(args)
client = koji.ClientSession(args.koji_url)
pkgid = client.getPackageID(args.package)
if not pkgid:
print(f"Package {args.package!r} not found!", file=sys.stderr)
return 1
def main_sequential_builds_algo(args, client, pkgid):
n_builds = 1
last_build = last_version = None
for build in client.listBuilds(pkgid, type="rpm", queryOpts={"order": "-nvr"}):
@ -79,5 +77,25 @@ def main(args):
)
def main_holistic_heuristic_algo(args, client, pkgid):
raise NotImplementedError()
def main(args):
""" Main method. """
args = get_cli_arguments(args)
client = koji.ClientSession(args.koji_url)
pkgid = client.getPackageID(args.package)
if not pkgid:
print(f"Package {args.package!r} not found!", file=sys.stderr)
return 1
if args.algorithm == "sequential_builds":
main_sequential_builds_algo(args, client, pkgid)
elif args.algorithm == "holistic_heuristic":
main_holistic_heuristic_algo(args, client, pkgid)
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))