#!/usr/bin/env sh
#
# git-standup - show git commits suitable for a daily standup
#
# works over weekends.

while getopts ':hx' opt; do
  case "${opt}" in
    h)
      awk 'NR == 1 { next } /^$/ { exit } { print substr($0, 3) }' "$0"
      exit
      ;;
    x)
      set -x
      ;;
    \? | *)
      printf "%s: Unrecognized option: '-%c'\n" "${0##*/}" "${OPTARG}" >&2
      exit 1
      ;;
  esac
done
shift "$((OPTIND - 1))"

author="$(git config user.email)"
# shellcheck disable=SC2016
date_rel="$(date +%w | xe -s '
if [ "$1" -eq 1 ]
then
  echo 3 days ago
else
  echo 1 day ago
fi')"

git log --reverse --pretty=format:'- %s' --all --since=@"${date_rel}" --author="${author}"
