fix: add default value to stats arg

This commit is contained in:
josix 2025-03-14 20:16:03 +08:00
parent 3b40edec93
commit 58351eb391
No known key found for this signature in database
GPG key ID: EF4F614562B02881
2 changed files with 7 additions and 2 deletions

View file

@ -557,7 +557,7 @@ def get_parser(default_config_files, git_root):
"--stats",
metavar="REVISIONS",
nargs="?",
const="",
const="HEAD",
help="Show code changes statistics between revisions",
)

View file

@ -1492,7 +1492,7 @@ class Commands:
/stats Compare against main/master branch
/stats <revision> Compare against specific revision
/stats rev1..rev2 Compare between two specific revisions
Examples:
/stats Show stats vs main/master branch
/stats HEAD~5 Show stats vs 5 commits ago
@ -1523,6 +1523,11 @@ class Commands:
source_revision, target_revision = args.split("..") if ".." in args else (args, "HEAD")
commits = get_all_commit_hashes_between_tags(source_revision, target_revision)
commits = [commit[:hash_len] for commit in commits] if commits else []
if not commits:
self.io.tool_error(
f"There are no commits between the specified revisions from {source_revision} to {target_revision}."
)
return
authors = get_commit_authors(commits)
# Get files changed between revisions