this repo has no description
at main 1.3 kB view raw
1#!/bin/bash 2 3# Generates git changelog grouped by day 4# 5# optional parameters 6# -a, --author to filter by author 7# -s, --since to select start date 8# -u, --until to select end date 9 10git-log-by-day () { 11 local NEXT=$(date +%F) 12 13 local RED="\x1B[31m" 14 local YELLOW="\x1B[32m" 15 local BLUE="\x1B[34m" 16 local RESET="\x1B[0m" 17 18 local SINCE="1970-01-01" 19 local UNTIL=$NEXT 20 21 for i in "$@" 22 do 23 case $i in 24 -a=*|--author=*) 25 local AUTHOR="${i#*=}" 26 shift 27 ;; 28 -s=*|--since=*) 29 SINCE="${i#*=}" 30 shift 31 ;; 32 -u=*|--until=*) 33 UNTIL="${i#*=}" 34 shift 35 ;; 36 *) 37 # unknown option 38 ;; 39 esac 40 done 41 42 local LOG_FORMAT=" %Cgreen*%Creset %s" 43 44 if [ -z "$AUTHOR" ] 45 then 46 LOG_FORMAT="$LOG_FORMAT %Cblue(%an)%Creset" 47 else 48 echo 49 echo -e "${BLUE}Logs filtered by author: ${AUTHOR}${RESET}" 50 fi 51 52 git log --no-merges --author="${AUTHOR}" --since="${SINCE}" --until="${UNTIL}" --format="%cd" --date=short | sort -u | while read DATE ; do 53 54 local GIT_PAGER=$(git log --no-merges --reverse --format="${LOG_FORMAT}" --since="${DATE} 00:00:00" --until="${DATE} 23:59:59" --author="${AUTHOR}") 55 56 if [ ! -z "$GIT_PAGER" ] 57 then 58 echo 59 echo -e "${RED}[$DATE]${RESET}" 60 echo -e "${GIT_PAGER}" 61 fi 62 63 done 64} 65 66git-log-by-day "$@" | less -R