mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
effort: rename 'file' to 'path' to be more accurate
This commit is contained in:
parent
2113e8c1d7
commit
4527656f7c
|
|
@ -54,13 +54,13 @@ color_for() {
|
|||
}
|
||||
|
||||
#
|
||||
# compute the effort of the given <file ...>
|
||||
# compute the effort of the given <path ...>
|
||||
#
|
||||
|
||||
effort() {
|
||||
file=$1
|
||||
path=$1
|
||||
local commit_dates
|
||||
commit_dates=`dates "$file"`
|
||||
commit_dates=`dates "$path"`
|
||||
[ $? -gt 0 ] && exit 255
|
||||
|
||||
# Ensure it's not just an empty line
|
||||
|
|
@ -77,9 +77,9 @@ effort() {
|
|||
|
||||
# commits
|
||||
color_for $(( $commits - $above ))
|
||||
len=${#file}
|
||||
len=${#path}
|
||||
dot="."
|
||||
f_dot="$file"
|
||||
f_dot="$path"
|
||||
i=0 ; while test $i -lt $((45-$len)) ; do
|
||||
f_dot=$f_dot$dot
|
||||
i=$(($i+1))
|
||||
|
|
@ -100,7 +100,7 @@ effort() {
|
|||
|
||||
heading() {
|
||||
echo
|
||||
printf " %-45s %-10s %s\n" 'file' 'commits' 'active days'
|
||||
printf " %-45s %-10s %s\n" 'path' 'commits' 'active days'
|
||||
echo
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ sort_effort() {
|
|||
above_index=0
|
||||
has_above=false
|
||||
next_is_above=false
|
||||
num_files=0
|
||||
num_paths=0
|
||||
|
||||
# Some implementations of `seq` gives "1\n0" for seq 0
|
||||
if [ $# -gt 0 ] ; then
|
||||
|
|
@ -145,7 +145,7 @@ if [ $# -gt 0 ] ; then
|
|||
--*)
|
||||
;;
|
||||
*)
|
||||
num_files=$(( num_files + 1 ))
|
||||
num_paths=$(( num_paths + 1 ))
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
|
@ -159,7 +159,7 @@ fi
|
|||
|
||||
args_before_above=`printf " %q" "${@:1:$above_index}"`
|
||||
|
||||
num_args=$(( i - num_files ))
|
||||
num_args=$(( i - num_paths ))
|
||||
if $has_above ; then offset=2 ; else offset=0 ; fi
|
||||
from=$(( 1 + above_index + offset ))
|
||||
len=$(( num_args - $(( above_index + offset)) ))
|
||||
|
|
@ -171,15 +171,15 @@ shift $num_args
|
|||
|
||||
export args_to_git_log
|
||||
|
||||
# [file ...]
|
||||
# [path ...]
|
||||
|
||||
declare -a files=()
|
||||
declare -a paths=()
|
||||
if test $# -ge 1; then
|
||||
files=("$@")
|
||||
paths=("$@")
|
||||
else
|
||||
save_ifs=$IFS
|
||||
IFS=`echo -en "\n\b"`
|
||||
files=(`git ls-files`)
|
||||
paths=(`git ls-files`)
|
||||
IFS=$safe_ifs
|
||||
unset save_ifs
|
||||
fi
|
||||
|
|
@ -207,10 +207,10 @@ if [ $? -eq 0 ] ; then
|
|||
fi
|
||||
|
||||
heading
|
||||
# send files to effort
|
||||
printf "%s\0" "${files[@]}" | xargs -0 -n 1 -P 4 -I % bash $bash_params -c "effort \"%\"" | tee $tmp
|
||||
# send paths to effort
|
||||
printf "%s\0" "${paths[@]}" | xargs -0 -n 1 -P 4 -I % bash $bash_params -c "effort \"%\"" | tee $tmp
|
||||
|
||||
# if more than one file, sort and print
|
||||
# if more than one path, sort and print
|
||||
test "$(wc -l $tmp | awk '{print $1}')" -gt 1 && sort_effort
|
||||
echo
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue