-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommitdeploy
executable file
·23 lines (23 loc) · 1.1 KB
/
commitdeploy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# commits current changes to after auto-generating a commit msg if necessary and
# auto-editing debug.js to inject commit message
[ `git rev-parse --abbrev-ref HEAD` != "master" ] && echo "Not on master branch. Aborting" && exit 1
if [[ -z $1 ]]
then
echo "No args supplied, using default commit message"
MESSAGE="commitdeploy scripted commit on master performed on host `hostname` at `date`"
else
echo "Using provided argument list as commit message"
MESSAGE="$*" #not "$@"; we *want* to smash into single string
fi
# apply message to code
DELIM='|'
# make sed call robust by checking no collision between delimiter and replacement string
[[ $MESSAGE == *$DELIM* ]] && echo "Delimiter found in message string, Aborting" && exit 2
git commit -a -m"$MESSAGE"
git checkout gh-pages
git pull
git merge -Xtheirs master --no-commit
MASTER_COMMIT=`git log master -1 --format='%h %s'`
sed -i_bak "s$DELIM#%.*%#$DELIM#% $MASTER_COMMIT %#$DELIM" public/debug.js && git add public/debug.js && git commit -m"scripted update of code from master at $MASTER_COMMIT" && git push origin master gh-pages
git checkout master