Last active
December 14, 2015 07:42
-
-
Save yszheda/61760ea52ee437f34b33 to your computer and use it in GitHub Desktop.
auto generate your daily work report by scanning your commits in the git repo, and send the mail to your boss.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SMTP_URL="" | |
USER="" | |
SENDER="" | |
RECEIVER="" | |
DATE=`date +%Y-%m-%d` | |
REPORT="" | |
./gen_daily_report.sh $SENDER $RECEIVER $REPORT | |
echo "Please enter the password:" | |
read -s -p Password: password | |
curl -n --ssl-reqd \ | |
--mail-from ${SENDER} --mail-rcpt ${RECEIVER} \ | |
--url ${SMTP_URL} \ | |
--upload-file ${REPORT} \ | |
--user ${USER}":"${password} --insecure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REPO_PATH= | |
AUTHOR="" | |
DATE=`date +%Y-%m-%d` | |
declare -a branches=(brach1 branch2) | |
TMP_FILE=/tmp/${DATE}.log | |
SENDER=$1 | |
RECEIVER=$2 | |
REPORT=$3 | |
# write header | |
echo "From: <${SENDER}>" > ${REPORT} | |
echo "To: <${RECEIVER}>" >> ${REPORT} | |
echo "Subject: Daily-Report-${DATE}" >> ${REPORT} | |
echo "MIME-Version: 1.0" >> ${REPORT} | |
echo "Content-Transfer-Encoding: 8bit" >> ${REPORT} | |
echo "Content-Type: text/plain;charset=utf-8" >> ${REPORT} | |
# write content | |
echo "Today's work:" >> $REPORT | |
cd ${REPO_PATH} | |
current_branch=`git symbolic-ref --short HEAD` | |
git stash | |
touch ${TMP_FILE} | |
for branch in ${branches[@]}; do | |
git checkout ${branch} | |
git log --since=0am --author=${AUTHOR} --oneline | cut -f 2- -d ' ' >> ${TMP_FILE} | |
done | |
cat ${TMP_FILE} | uniq >> ${REPORT} | |
rm ${TMP_FILE} | |
git checkout ${current_branch} | |
git stash pop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment