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
havocesp marked this conversation as resolved.
Show resolved Hide resolved
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"
havocesp marked this conversation as resolved.
Show resolved Hide resolved
}

__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