have you ever wanted to lose all of your followers by tweeting every single commit message to the world?
adapted from: https://gist.github.com/kylefrost/f3841e76749dc64f4b5e
changed to do the actual twitter post in python using Tweepy because the oauth-sign and http-post install from tar.gz was giving me problems and python is just easier. hopefully this makes it a bit more usable for someone else. enjoy!
- Get your developer tokens from https://apps.twitter.com/ and make sure your permissions are set to "Read and Write"
https://www.slickremix.com/docs/how-to-get-api-keys-and-tokens-for-twitter/
1a. Paste the 4 keys into the post_commit_hook.py in the section below.
def main(): # Get these values from https://apps.twitter.com/ # See more detailed instructions in the README.md cfg = { "consumer_key" : "YOUR VALUE", "consumer_secret" : "YOUR VALUE", "access_token" : "YOUR VALUE", "access_token_secret" : "YOUR VALUE" }-
Install dependency (its just
tweepy), runpip install -r requirements.txt -
Go to the local repository that you want to have commits tweeted from and find the
.gitfolder. Note that most operating systems have folders that start with "." hidden. To unhide folders on Mac OSX pressCommand+Shift+.
-
Place the 2 files
post-commitandpost_commit_hook.pyfrom this repository into theyour_repo/.git/hooks/directory -
Make the
post-commitfile executable by runningchmod a+x post-commitfrom withinyour_repo/.git/hooks/directory
- Edit lines 5 and 28 in
post-commitfile to point to your repository's local directory and repository's git/hooks directory respectively. See below for an example of what your edits might look like:
Line 5: export PATH=$PATH:~/Desktop/Code/MyCodeRepository/.git/hooks Line 28: python ~/Desktop/Code/MyCodeRepository/.git/hooks/post_commit_hook.py $tweet Its still pretty early but if you have suggestions, thoughts, feedback, criticism, etc feel free to open a PR or submit an Issue.
Thanks in advance 😊
If ya feeling generous, hollr @ the kid ❤️
https://www.paypal.me/hijodelsol
BTC: 3EbMygEoo8gqgPHxmqa631ZVSwgWaoCj3m
ETH: 0x2F2604AA943dB4E7257636793F38dD3B1808A9e7
LTC: MQVgzNDgw43YzyUg3XmH3jQ7L8ndVswmN3

