Skip to content

Commit 398ba04

Browse files
committed
Add dm repo show command
1 parent 4298881 commit 398ba04

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

django_mongodb_cli/repo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,18 @@ def reset_repo(name):
448448
)
449449

450450

451+
@repo.command()
452+
def show(
453+
ctx: typer.Context,
454+
repo_name: str = typer.Argument(..., help="Repository name"),
455+
commit_hash: str = typer.Argument(..., help="Commit hash to show"),
456+
):
457+
"""Show the git diff for a specific commit hash in the given repository."""
458+
repo = Repo()
459+
repo.ctx = ctx
460+
repo.show_commit(repo_name, commit_hash)
461+
462+
451463
@repo.command()
452464
def set_default(
453465
repo_name: str = typer.Argument(None),

django_mongodb_cli/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,19 @@ def get_repo_diff(self, repo_name: str) -> None:
466466
except GitCommandError as e:
467467
self.err(f"❌ Failed to diff working tree: {e}")
468468

469+
def show_commit(self, repo_name: str, commit_hash: str) -> None:
470+
"""Show the diff for a specific commit hash in the given repository."""
471+
self.info(f"Showing diff for {repo_name}@{commit_hash}")
472+
path, repo = self.ensure_repo(repo_name)
473+
if not repo or not path:
474+
return
475+
476+
try:
477+
output = repo.git.show(commit_hash)
478+
typer.echo(output)
479+
except GitCommandError as e:
480+
self.err(f"❌ Failed to show commit {commit_hash}: {e}")
481+
469482
def _list_repos(self) -> tuple[set, set]:
470483
map_repos = set(self.map.keys())
471484

0 commit comments

Comments
 (0)