Skip to content

Commit

Permalink
cfbs status now displays module versions in addition to commit hashes
Browse files Browse the repository at this point in the history
Changelog: Title

Ticket: ENT-9556
Signed-off-by: jakub-nt <[email protected]>
  • Loading branch information
jakub-nt committed Jul 22, 2024
1 parent 95c5f62 commit 32b0850
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 5 additions & 1 deletion cfbs/cfbs_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def save(self):
f.write(data)

def longest_module_key_length(self, key) -> int:
return max((len(m.get(key, "")) for m in self["build"])) if self.get("build") else 0
return (
max((len(m.get(key, "")) for m in self["build"]))
if self.get("build")
else 0
)

def add_with_dependencies(self, module, remote_config=None, dependent=None):
if type(module) is list:
Expand Down
18 changes: 14 additions & 4 deletions cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,28 @@ def status_command() -> int:
if not modules:
return 0
print("\nModules:")
max_length = config.longest_module_key_length("name")
max_name_length = config.longest_module_key_length("name")
max_version_length = config.longest_module_key_length("version")
counter = 1
for m in modules:
if m["name"].startswith("./"):
status = "Copied"
commit = pad_right("local", 40)
version = "local"
commit = pad_right("", 40)
else:
path = get_download_path(m)
status = "Downloaded" if os.path.exists(path) else "Not downloaded"
version = m.get("version", "")
commit = m["commit"]
name = pad_right(m["name"], max_length)
print("%03d %s @ %s (%s)" % (counter, name, commit, status))
name = pad_right(m["name"], max_name_length)
version = pad_right(version, max_version_length)
version_with_commit = version + " "
if m["name"].startswith("./"):
version_with_commit += " "
else:
version_with_commit += "/"
version_with_commit += " " + commit
print("%03d %s @ %s (%s)" % (counter, name, version_with_commit, status))
counter += 1

return 0
Expand Down

0 comments on commit 32b0850

Please sign in to comment.