Coverage for heliumcli/actions/setbuild.py: 97.22%
36 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-01 17:33 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-01 17:33 +0000
1import os
2import subprocess
4import git
6from .. import utils
8__author__ = "Alex Laird"
9__copyright__ = "Copyright 2018, Helium Edu"
10__version__ = "1.5.0"
13class SetBuildAction:
14 def __init__(self):
15 self.name = "set-build"
16 self.help = "Set all projects to the specified build, which may be a versioned release or a branch"
18 def setup(self, subparsers):
19 parser = subparsers.add_parser(self.name, help=self.help)
20 parser.add_argument("version", help="The build version to be deployed, which may be a version or a branch")
21 parser.set_defaults(action=self)
23 def run(self, args):
24 config = utils.get_config()
25 projects_dir = utils.get_projects_dir()
27 if config["projectsRelativeDir"] != ".":
28 root_dir = os.path.abspath(os.path.join(projects_dir, ".."))
29 if os.path.exists(os.path.join(root_dir, ".git")):
30 print(utils.get_repo_name(root_dir, config["remoteName"]))
32 repo = git.Repo(root_dir)
33 repo.git.fetch(tags=True, prune=True)
34 repo.git.checkout(args.version)
36 print("")
38 for project in utils.get_projects(config):
39 print(project)
41 if config["projectsRelativeDir"] != ".":
42 project_path = os.path.join(projects_dir, project)
43 else:
44 project_path = os.path.join(projects_dir)
46 repo = git.Repo(project_path)
47 repo.git.fetch(tags=True, prune=True)
48 repo.git.checkout(args.version)
50 subprocess.call(["make", "install", "-C", project_path])
52 print("")