Skip to content

Commit a334630

Browse files
aclark4lifeCopilot
andcommitted
Add -a/--all flag to dbx log for all cloned repos
Works the same as sync -a: iterates all cloned repositories across all non-global groups and shows git log output. dbx log -a dbx log -a --oneline -n 5 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent af5e1a4 commit a334630

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

  • src/dbx_python_cli/commands

src/dbx_python_cli/commands/log.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99
from dbx_python_cli.utils.output import paginate_output, should_use_pager
1010
from dbx_python_cli.utils.repo import (
11+
find_all_repos,
12+
find_repo_by_name,
1113
get_base_dir,
1214
get_config,
15+
get_global_groups,
1316
get_projects_dir,
1417
get_repo_groups,
1518
is_flat_mode,
1619
)
17-
from dbx_python_cli.utils.repo import find_all_repos, find_repo_by_name
1820

1921
# Create a Typer app that will act as a single command
2022
app = typer.Typer(
@@ -43,6 +45,12 @@ def log_callback(
4345
"-g",
4446
help="Show logs for all repositories in a group",
4547
),
48+
all_groups: bool = typer.Option(
49+
False,
50+
"--all",
51+
"-a",
52+
help="Show logs for all cloned repositories across all groups",
53+
),
4654
project: str = typer.Option(
4755
None,
4856
"--project",
@@ -55,6 +63,7 @@ def log_callback(
5563
5664
dbx log <repo_name> [git_args...]
5765
dbx log -g <group> [git_args...]
66+
dbx log -a [git_args...]
5867
dbx log --project <project> [git_args...]
5968
6069
Examples::
@@ -65,6 +74,7 @@ def log_callback(
6574
dbx log mongo-python-driver --graph -n 5 # Show graph with last 5 commits
6675
dbx log -g pymongo -n 20 # Show last 20 commits for all repos
6776
dbx log -g pymongo --oneline -n 5 # Show last 5 commits in oneline format
77+
dbx log -a --oneline -n 5 # Show last 5 commits for all cloned repos
6878
dbx log --project myproject -n 5 # Show last 5 commits for a project
6979
"""
7080
# Get verbose flag from parent context
@@ -94,6 +104,39 @@ def log_callback(
94104
typer.echo(f"❌ Error: {e}", err=True)
95105
raise typer.Exit(1)
96106

107+
# Handle all groups option
108+
if all_groups:
109+
groups = get_repo_groups(config)
110+
global_group_names = get_global_groups(config)
111+
non_global_groups = [g for g in groups.keys() if g not in global_group_names]
112+
113+
if not non_global_groups:
114+
typer.echo("❌ Error: No groups found in configuration.", err=True)
115+
raise typer.Exit(1)
116+
117+
all_repos = find_all_repos(base_dir, config)
118+
target_repos = [r for r in all_repos if r["group"] in non_global_groups]
119+
120+
if not target_repos:
121+
typer.echo("❌ Error: No repositories found in any group.", err=True)
122+
typer.echo("\nClone repositories using: dbx clone -a")
123+
raise typer.Exit(1)
124+
125+
output_parts = [
126+
f"Showing logs for {len(target_repos)} repository(ies) across {len(non_global_groups)} group(s):\n"
127+
]
128+
129+
for repo_info in target_repos:
130+
log_output = _get_git_log_output(
131+
repo_info["path"], repo_info["name"], git_args, verbose
132+
)
133+
if log_output:
134+
output_parts.append(log_output)
135+
136+
use_pager = should_use_pager(ctx, command_default=False)
137+
paginate_output("\n".join(output_parts), use_pager)
138+
return
139+
97140
# Handle group option
98141
if group:
99142
groups = get_repo_groups(config)
@@ -153,6 +196,7 @@ def log_callback(
153196
typer.echo("❌ Error: Repository name, group, or project is required", err=True)
154197
typer.echo("\nUsage: dbx log <repo_name> [git_args...]")
155198
typer.echo(" or: dbx log -g <group> [git_args...]")
199+
typer.echo(" or: dbx log -a [git_args...]")
156200
typer.echo(" or: dbx log --project <project> [git_args...]")
157201
raise typer.Exit(1)
158202

0 commit comments

Comments
 (0)