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

Columns in git-effort adopt to file length #633

Merged
merged 3 commits into from
Mar 6, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bin/git-effort
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ above=0
# if the output won't be printed to tty, disable the color
test -t 1 && to_tty=true
color=
columns=45
Copy link
Collaborator

Choose a reason for hiding this comment

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

colums=45 seems duplicate now, because you will calculate it from longest filename later.

Copy link
Author

@nschlimm nschlimm Mar 5, 2017

Choose a reason for hiding this comment

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

taken that out. I have another branch where you can set the columns as option on the command line when calling git effort, this was the default setting. however it's not necessary here ...


#
# print usage message
Expand Down Expand Up @@ -104,7 +105,7 @@ effort() {
len=${#path}
dot="."
f_dot="$path"
i=0 ; while test $i -lt $((45-$len)) ; do
i=0 ; while test $i -lt $(( $columns - $len )) ; do
f_dot=$f_dot$dot
i=$(($i+1))
done
Expand All @@ -124,7 +125,7 @@ effort() {

heading() {
echo
printf " %-45s %-10s %s\n" 'path' 'commits' 'active days'
printf " %-${columns}s %-10s %s\n" 'path' 'commits' 'active days'
echo
}

Expand Down Expand Up @@ -177,6 +178,10 @@ fi
args_to_git_log="${args_to_git_log#\ \'\'}"
export args_to_git_log

# set column width to match longest filename
columns=$(( $(git ls-files | awk '{ print length, $0 }' | sort -rn | head -1 | cut -f1 -d' ') + 5 ))
export columns

# [path ...]

if test "${#paths}" -eq 0; then
Expand Down