Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --full flag to "git-count" #1105

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
9 changes: 5 additions & 4 deletions bin/git-count
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash

if test "$1" = "--all"; then
if test "$1" = "--all" || test "$1" = "-a"; then
git shortlog -n -s | awk '{print substr($0,index($0,$2)) " (" $1 ")"}'
echo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also output total for --all.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this change, the output will be different.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@havocesp
This comment is not resolved yet.

elif test "$1" = "--full" || test "$1" = "-f"; then
git rev-list --all --tags --branches --full-history --no-max-parents --no-min-parents --count
else
echo total "$(git rev-list --count HEAD)"
fi

echo total "$(git rev-list --count HEAD)"
2 changes: 1 addition & 1 deletion etc/bash_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ _git_contrib(){
}

_git_count(){
__gitcomp "--all"
__gitcomp "--all --full -a -f"
}

__git_cp(){
Expand Down
4 changes: 2 additions & 2 deletions etc/git-extras-completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ _git-contrib() {
':author:__gitex_author_names'
}


_git-count() {
_arguments \
'--all[detailed commit count]'
'(-a --all)'{-a,--all}'[detailed commit count]' \
'(-f --full)'{-f,--full}'[output a full commits count including all, branches, tags, ...]'
}

_git-create-branch() {
Expand Down
3 changes: 2 additions & 1 deletion etc/git-extras.fish
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ end
complete -c git -f -n '__fish_git_using_command coauthor; and __fish_git_arg_number 2' -a '(__fish_git_extra_coauthor_name)'
complete -c git -f -n '__fish_git_using_command coauthor; and __fish_git_arg_number 3' -a '(__fish_git_extra_coauthor_email)'
# count
complete -c git -f -n '__fish_git_using_command count' -l all -d 'detailed commit count'
complete -c git -f -n '__fish_git_using_command count' -s a -l all -d 'detailed commit count'
complete -c git -f -n '__fish_git_using_command count' -s f -l full -d 'output a full commits count including all, branches, tags, ...'
# create-branch
complete -c git -x -n '__fish_git_using_command create-branch' -s r -l remote -a '(__fish_git_unique_remote_branches)' -d 'setup remote tracking branch'
# delete-branch
Expand Down
11 changes: 10 additions & 1 deletion man/git-count.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
\fBgit\-count\fR \- Show commit count
.
.SH "SYNOPSIS"
\fBgit\-count\fR [\-\-all]
\fBgit\-count\fR [\-a\|\-\-all] [\-f\|\-\-full]
.
.SH "DESCRIPTION"
Show commit count\.
.
.SH "OPTIONS"
\-\-all
\-\-full
.
.P
Show commit count details\.
Expand Down Expand Up @@ -65,6 +66,14 @@ $ git count \-\-all
.
.fi
.
.nf

$ git count \-\-full

1904
.
.fi
.
.IP "" 0
.
.SH "AUTHOR"
Expand Down
8 changes: 7 additions & 1 deletion man/git-count.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion man/git-count.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ git-count(1) -- Show commit count

## SYNOPSIS

`git-count` [--all]
`git-count` [-a|--all] [-f|--full]

## DESCRIPTION

Expand All @@ -12,6 +12,7 @@ git-count(1) -- Show commit count
## OPTIONS

--all
--full

Show commit count details.

Expand All @@ -23,6 +24,12 @@ git-count(1) -- Show commit count
$ git count

total 1844

Output full commits total:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add more words to explain the difference between the regular total and the full total.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regular total count from current commit to the first one and the full total count all commits available at repository.


$ git count --full

1904

Output verbose commit count details:

Expand Down
Loading