-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpost-commit_template
28 lines (23 loc) · 1.01 KB
/
post-commit_template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
# PATH to the repository of interest
export PATH=$PATH:{{MY_REPO_PATH}}.git/hooks
toplevel_path=`git rev-parse --show-toplevel`
toplevel_dir=`basename "$toplevel_path"`
# this variable holds the branch you are working on
branch=`git rev-parse --abbrev-ref HEAD`
# this variable holds the actual commit message
subject=`git log --pretty=format:%s -n1`
# this variables adds some hashtags to your tweet "#code #(name of your repo)"
hashtags="Repository: #$toplevel_dir"
#the tweet itself is thee hashtags plus the branch name plus the commit message
tweet=$hashtags' ['$branch']: "'$subject'"'
# truncate tweets that are longer than 280 characters
if [ ${#tweet} -gt 280 ]
then
tweet_trunc=$(echo $tweet | cut -c1-277)
tweet=${tweet_trunc}...
fi
echo $tweet
# Write a full path to where you put the post_commit_hook.py so it is executed
# the $tweet variable is the command line argument that will be passed to the python script
python {{MY_REPO_PATH}}.git/hooks/post_commit_hook_autogen.py $tweet