Skip to content

Instantly share code, notes, and snippets.

@vishalbasnet23
Created November 25, 2015 06:19
Show Gist options
  • Save vishalbasnet23/4a73ceecdb2d06380a1b to your computer and use it in GitHub Desktop.
Save vishalbasnet23/4a73ceecdb2d06380a1b to your computer and use it in GitHub Desktop.
Send Email of the git log for the day.
#!/bin/bash
todays_date="$(date +'%Y-%m-%d 09:00')"
current_date_with_time="$(date +'%Y-%m-%d %H:%M')"
printf "today's date is %s\n" "$todays_date"
printf "current date time is %s\n" "$current_date_with_time"
echo -n "Enter Project's name:"
read project_name #enter project name
git_dir="Your Git Directory"
if [ -d "Your Git Directory/$project_name" ]; then
# Control will enter here if $DIRECTORY exists.
cd "Your Git Directory/$project_name"
Message=$(git log --use-mailmap --after="$todays_date" --before="$current_date_with_time" --pretty=format:'%h : "%s" was done by %an%n')
mail_message=$Message
echo $mail_message
SUBJECT="Log"
RECEIVER="reciversmail"
#changereciveremail with the person's email you want to send
TEXT=$mail_message
SERVER_NAME=$HOSTNAME
SENDER=$(whoami)
USER="noreply"
MAIL_TXT="Subject: $SUBJECT\nFrom: $SENDER\nTo: $RECEIVER\n\n$TEXT"
echo -e $MAIL_TXT | sendmail -t
exit $?
echo "Mail Sent"
else
echo "Repo does not exists"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment