Coverage for heliumcli/actions/listbuilds.py: 62.50%
32 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-22 22:16 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-22 22:16 +0000
1import os
3import git
5from .. import utils
7__author__ = "Alex Laird"
8__copyright__ = "Copyright 2018, Helium Edu"
9__version__ = "1.5.0"
12class ListBuildsAction:
13 def __init__(self):
14 self.name = "list-builds"
15 self.help = "List available builds"
17 def setup(self, subparsers):
18 parser = subparsers.add_parser(self.name, help=self.help)
19 parser.add_argument("--latest", action="store_true", help="Only list the latest build")
20 parser.set_defaults(action=self)
22 def run(self, args):
23 config = utils.get_config()
24 projects_dir = utils.get_projects_dir()
26 if config["projectsRelativeDir"] != ".":
27 root_dir = os.path.abspath(os.path.join(projects_dir, ".."))
28 if os.path.exists(os.path.join(root_dir, ".git")):
29 print(utils.get_repo_name(root_dir, config["remoteName"]))
31 repo = git.Repo(root_dir)
32 repo.git.fetch(tags=True, prune=True)
33 version_tags = utils.sort_tags(repo.tags)
35 if len(version_tags) == 0:
36 print("No version tags have been created yet.")
38 return
40 if args.latest:
41 print(version_tags[-1])
42 else:
43 for tag in version_tags:
44 print(tag)
46 print("")