Skip to content

Commit

Permalink
Changed init --masterfiles implementation to add with commit instead …
Browse files Browse the repository at this point in the history
…of modify index version of masterfiles module

Previously, if the alternate masterfiles branch/commit had different steps they would not be included in cfbs.json

Ticket: CFE-4257
Changelog: title
  • Loading branch information
craigcomstock committed Sep 21, 2023
1 parent 3841df8 commit b451f92
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __init__(self, message):

_commands = OrderedDict()


# Decorator to specify that a function is a command (verb in the CLI)
# Adds the name + function pair to the global dict of commands
# Does not modify/wrap the function it decorates.
Expand Down Expand Up @@ -286,30 +287,25 @@ def init_command(index=None, masterfiles=None, non_interactive=False) -> int:
branch = masterfiles
to_add = "masterfiles"

if to_add:
ret = add_command([to_add])
if ret != 0:
return ret

if branch is not None:
config = CFBSConfig.get_instance()
module = config.get_module_from_build("masterfiles")
remote = module["repo"]
remote = "https://github.com/cfengine/masterfiles"
commit = ls_remote(remote, branch)
if commit is None:
user_error("Failed to add masterfiles from branch %s" % branch)
user_error(
"Failed to find branch or tag %s at remote %s" % (branch, remote)
)
log.debug("Current commit for masterfiles branch %s is %s" % (branch, commit))
module["url"] = remote
del module["repo"]
module["commit"] = commit
config.save()
to_add = "%s@%s" % (remote, commit)
if to_add:
ret = add_command([to_add])
if ret != 0:
return ret

return 0


@cfbs_command("status")
def status_command() -> int:

config = CFBSConfig.get_instance()
print("Name: %s" % config["name"])
print("Description: %s" % config["description"])
Expand Down

0 comments on commit b451f92

Please sign in to comment.