refactor: update format_tree_output function signature and usage
This commit is contained in:
parent
2652afa8d6
commit
7e83d68368
@ -188,13 +188,12 @@ async def commit_and_push_submodules():
|
||||
print(f"Submodule '{name}' stderr:\n{stderr.decode()}")
|
||||
|
||||
|
||||
def format_tree_output(base_path, submodule_diffs, commit):
|
||||
def format_tree_output(project_path, base_name, base_diff, submodule_diffs, commit):
|
||||
"""Format the output in a tree structure."""
|
||||
base_name = os.path.basename(base_path)
|
||||
base_diff = get_git_diff(base_path, True)
|
||||
|
||||
|
||||
output = [f"📦 {base_name}"]
|
||||
output.append(f"└── 📝 {commit[base_path]}:")
|
||||
output.append(f"└── 📝 {commit[project_path]}:")
|
||||
for line in base_diff.split("\n"):
|
||||
output.append(f" └── {line}")
|
||||
|
||||
@ -202,12 +201,12 @@ def format_tree_output(base_path, submodule_diffs, commit):
|
||||
output.append("└── 📚 Submodules:")
|
||||
for submodule_path, diff in submodule_diffs.items():
|
||||
name = os.path.basename(submodule_path)
|
||||
if submodule_path in commit:
|
||||
output.append(f" └── 📝 {commit[submodule_path]}:")
|
||||
|
||||
else:
|
||||
output.append(f" └── 📝 No changes:")
|
||||
output.append(f" └── 📦 {name}")
|
||||
if submodule_path in commit:
|
||||
output.append(f" └── 📝 {commit[submodule_path]}:")
|
||||
|
||||
else:
|
||||
output.append(f" └── 📝 ✓")
|
||||
for line in diff.split("\n"):
|
||||
output.append(f" └── {line}")
|
||||
|
||||
@ -218,6 +217,8 @@ async def push_code():
|
||||
git_user, git_pass, project_path = get_git_credentials()
|
||||
os.chdir(project_path)
|
||||
print(f"Changed to project path: {project_path}")
|
||||
base_name = os.path.basename(project_path)
|
||||
base_diff = get_git_diff(project_path, True)
|
||||
if await has_submodules():
|
||||
submodule_info = await get_submodule_info()
|
||||
for path in submodule_info:
|
||||
@ -263,7 +264,7 @@ async def push_code():
|
||||
print(stderr.decode())
|
||||
|
||||
# Format and print the tree output
|
||||
tree_output = format_tree_output(project_path, submodule_diffs, commit)
|
||||
tree_output = format_tree_output(project_path, base_name, base_diff, submodule_diffs, commit)
|
||||
print("\nProject Status:")
|
||||
print(tree_output)
|
||||
print()
|
||||
|
Loading…
Reference in New Issue
Block a user