Last active
May 21, 2022 09:12
-
-
Save hata6502/d3bb634ec9beb9443a040c90733284bd to your computer and use it in GitHub Desktop.
git push して Twitter に通知します。
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
#!/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 |
スクリプトを「git-twitter」として保存することで、gitwitter
ではなくgit twitter
としてコマンドを実行可能です。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
・環境要件
tweet コマンドをインストールする必要があります。
https://github.com/Hato6502/tweet
・インストール
/usr/local/bin などに直接配置します。
・使用例
・その他
push 先の URL などによって正常動作しない場合や、ツイート内容の調整をする場合は gitweet シェルスクリプトを直接改変します。
引数を指定すると、そのまま
git push
の引数になります。