Skip to content

Commit

Permalink
Merge pull request #147 from flyingcircusio/phil/multiple-environment…
Browse files Browse the repository at this point in the history
…s-per-branch

feat: versions.py: allow multiple environments per branch
  • Loading branch information
zagy authored Feb 14, 2024
2 parents dc634f7 + 8c1bfae commit 1cb0884
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Change the behaviour of the batou_ext.versions updater to allow environments to share a branch
15 changes: 7 additions & 8 deletions src/batou_ext/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,16 @@ def environment(self):
self._environment.load()
return self._environment

def set_environment_from_branch(self, branch):
def update_from_branch(self, branch: str):
envs = sorted(os.listdir(os.path.join(self.basedir, "environments")))
for env_name in envs:
env = batou.environment.Environment(env_name)
env.load()
if env.branch == branch:
if self.environment_name:
raise ValueError(
f"Branch {branch} is used in multiple enviornments, "
"cannot auto-update."
)
print(f"Updating environment: {env_name}")
self.environment_name = env_name
self.set_versions()

if not self.environment_name:
raise ValueError(
f"Branch {branch} is not used in any environment, "
Expand Down Expand Up @@ -157,11 +155,12 @@ def main():

if args.environment:
update.environment_name = args.environment
update.set_versions()
elif args.branch:
update.set_environment_from_branch(args.branch)
update.update_from_branch(args.branch)
else:
update.interactive()
update.set_versions()
update.set_versions()


if __name__ == "__main__":
Expand Down

0 comments on commit 1cb0884

Please sign in to comment.