submit-daily-report.sh 650 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. # Change the next two variables to the correct values
  3. start_month_offset=5; # Things started in May
  4. nickname="$(git config user.name)"
  5. month="$(date --date="-$start_month_offset months" +%-m)"
  6. dir="$nickname/$month/"
  7. nday="$(date --date="-1 day" +%-d)"
  8. file="$dir/$nday"
  9. mkdir -p "$dir"
  10. if [ ! -e "$file" ]
  11. then
  12. cat > "$file" <<EOF
  13. {
  14. "summary": "",
  15. "dedicated_hours":
  16. }
  17. EOF
  18. commit_message="[$nickname] added daily report $nday of month $month"
  19. else
  20. commit_message="[$nickname] updated daily report $nday of month $month"
  21. fi
  22. $EDITOR "$file"
  23. git pull
  24. git add "$file"
  25. git commit -m "$commit_message"
  26. git push