summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <bsima@groq.com>2024-04-15 18:14:59 -0700
committerBen Sima <bsima@groq.com>2024-04-15 18:15:19 -0700
commit427eb1c3ff5a52569d26bb046969c2f1690bbb6b (patch)
treec1aef7bae6bbb908684cc48ff0a8cb6689e8a7da
parenteb7706189a9d1050ea37b20d4ef7822ba60e14c0 (diff)
add author to git-activity
-rwxr-xr-xgit-activity10
1 files changed, 8 insertions, 2 deletions
diff --git a/git-activity b/git-activity
index 45135a4..5d5e09d 100755
--- a/git-activity
+++ b/git-activity
@@ -4,7 +4,7 @@ set -o nounset
function usage() {
cat <<EOF
-Usage: $0 [-h] [-n] [-s style]
+Usage: $0 [-h] [-n] [-s style] [-a name]
Display an activity graph (like the contribution graph on GitHub) for the
current git repository and branch
@@ -14,18 +14,24 @@ Available options:
-h, --help Print this help and exit
-n, --no-space Remove spaces between week columns
-s, --style Sets style of the graph: square (default), block, or plus
+-a, --author Select for an author (passed to git log)
EOF
}
# Parse options
space=" "
style=square
+author=""
while [[ $# -gt 0 ]]; do
case "$1" in
-s|--style)
style="$2"
shift 2
;;
+ -a|--author)
+ author="$2"
+ shift 2
+ ;;
-n|--no-space) space="" ;;
-h|--help)
usage
@@ -77,7 +83,7 @@ while read -r commits_n commits_date; do
(( commits_n > commits_max )) && commits_max=$commits_n
date_diff=$(( ($(_date --date="${commits_date} 13:00 UTC" "+%s") - since) / (60*60*24) ))
commits_per_day["${date_diff}"]=$commits_n
-done <<< $(git log --since="${since}" --date=short --pretty=format:'%ad' | uniq -c)
+done <<< $(git log --author="${author}" --since="${since}" --date=short --pretty=format:'%ad' | uniq -c)
# Print name of months
current_month=$(_date "+%b")