Skip to content

Instantly share code, notes, and snippets.

@hata6502
Last active May 21, 2022 09:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hata6502/d3bb634ec9beb9443a040c90733284bd to your computer and use it in GitHub Desktop.
Save hata6502/d3bb634ec9beb9443a040c90733284bd to your computer and use it in GitHub Desktop.
git push して Twitter に通知します。
#!/bin/bash
url=`git config --get remote.origin.url`
domain=${url#*@}
domain=${domain#https://}
domain=${domain/:/}
branch=`git rev-parse --abbrev-ref HEAD`
tweet=""
if git rev-parse --verify origin/${branch} >/dev/null 2>&1
then
remote=${branch}
else
remote=HEAD
fi
tweet="${tweet}https://${domain}/compare/`git rev-parse --short origin/${remote}`...`git rev-parse --short ${branch}`\n"
tweet="${tweet}`basename ${url}`/${branch} を更新しました。\n"
log=`git log --pretty=format:"・%s\n" origin/${remote}..${branch}`
tweet="${tweet}${log}"
if git push $@
then
echo -e ${tweet} | tweet
fi
@hata6502
Copy link
Author

スクリプトを「git-twitter」として保存することで、gitwitterではなくgit twitterとしてコマンドを実行可能です。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment