add date information to git-blame

This commit is contained in:
Maxime Coste 2013-04-02 18:57:02 +02:00
parent 3a351aa436
commit aa44d05ede

View File

@ -31,10 +31,11 @@ def git-blame %{
setb git_blame_flags '' setb git_blame_flags ''
%sh{ ( %sh{ (
declare -A authors declare -A authors
declare -A dates
send_flags() { send_flags() {
if [[ -z "$line" ]]; then return; fi if [[ -z "$line" ]]; then return; fi
text="${sha:0:8} ${authors[$sha]}" text="${sha:0:8} ${dates[$sha]} ${authors[$sha]}"
flag="$line:black:$text" flag="$line|black|$text"
for (( i=1; $i < $count; i++ )); do for (( i=1; $i < $count; i++ )); do
flag="$flag;$(($line+$i))|black|$text" flag="$flag;$(($line+$i))|black|$text"
done done
@ -48,6 +49,8 @@ def git-blame %{
count=${BASH_REMATCH[4]} count=${BASH_REMATCH[4]}
elif [[ $blame_line =~ author[^-](.*) ]]; then elif [[ $blame_line =~ author[^-](.*) ]]; then
authors[$sha]=${BASH_REMATCH[1]} authors[$sha]=${BASH_REMATCH[1]}
elif [[ $blame_line =~ author-time.([0-9]*) ]]; then
dates[$sha]="$(date -d @${BASH_REMATCH[1]} +'%F %T')"
fi fi
done; send_flags ) done; send_flags )
) >& /dev/null < /dev/null & } ) >& /dev/null < /dev/null & }