Created
June 7, 2013 08:51
-
-
Save krisanalfa/5727957 to your computer and use it in GitHub Desktop.
Post your 'commit message' and your 'commit url' to Twitter when you push your code to GitHub.
This file contains 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
#!/usr/bin/env bash | |
# File name: GitPostToTwitter | |
# Author: Krisan Alfa Timur | |
command -v twidge > /dev/null | |
if [[ -d .git ]]; then | |
if [[ $? -eq 0 ]]; then | |
read_git_hub=$(cat .git/config | grep github); | |
if [[ $read_git_hub == "" ]]; then | |
echo "This commit will not posted on Twitter"; | |
git push origin master | |
else | |
hashtag=$(cat .git/config | grep url | awk -F: '{print $2}' | sed 's/\.git$//g' | awk -F/ '{print $2}'); | |
repo=$(cat .git/config | grep url | awk -F: '{print $2}' | sed 's/\.git$//g'); | |
github_url="https://www.github.com"; | |
comit_message=$(git log --pretty=oneline | head -n 1 | cut -d\ -f2-); | |
rev_number=$(git log --pretty=oneline | head -n 1 | awk -F ' ' '{print $1}'); | |
url="$github_url/$repo/commit/$rev_number"; | |
echo "Will be posted on Twitter" | |
echo "GitHub URL = $url"; | |
echo "Commit message = $comit_message"; | |
twidge update "Update on $hashtag. $comit_message $url #$hashtag"; | |
git push origin master | |
fi | |
else | |
echo "You don't have twidge installed on your system. Please Googling to find out how." | |
fi | |
else | |
echo "Not in git repo folder. Exiting." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment