plugins: git: Fix git_stats

Also remove uneeded newline
pull/1816/head
Noah Gorny 2021-02-02 13:28:56 +02:00
parent 5cb52fa239
commit 75058ebf22
1 changed files with 8 additions and 5 deletions

View File

@ -1,5 +1,4 @@
# shellcheck shell=bash # shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'git helper functions' about-plugin 'git helper functions'
@ -188,13 +187,17 @@ function git_stats {
echo '-------------------' echo '-------------------'
echo "Statistics for: $a" echo "Statistics for: $a"
echo -n "Number of files changed: " echo -n "Number of files changed: "
git log "$LOGOPTS" --all --numstat --format="%n" --author="$a" | cut -f3 | sort -iu | wc -l # shellcheck disable=SC2086
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f3 | sort -iu | wc -l
echo -n "Number of lines added: " echo -n "Number of lines added: "
git log "$LOGOPTS" --all --numstat --format="%n" --author="$a" | cut -f1 | awk '{s+=$1} END {print s}' # shellcheck disable=SC2086
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f1 | awk '{s+=$1} END {print s}'
echo -n "Number of lines deleted: " echo -n "Number of lines deleted: "
git log "$LOGOPTS" --all --numstat --format="%n" --author="$a" | cut -f2 | awk '{s+=$1} END {print s}' # shellcheck disable=SC2086
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f2 | awk '{s+=$1} END {print s}'
echo -n "Number of merges: " echo -n "Number of merges: "
git log "$LOGOPTS" --all --merges --author="$a" | grep -c '^commit' # shellcheck disable=SC2086
git log $LOGOPTS --all --merges --author="$a" | grep -c '^commit'
done done
else else
echo "you're currently not in a git repository" echo "you're currently not in a git repository"