3 if [[ -n "${PPG_DEBUG}" ]]; then
7 PPG_EXEC_PATH
=$
( dirname $
(readlink
-f "${BASH_SOURCE[0]}" ) )
8 GIT_EXEC_PATH
=$
(git
--exec-path)
9 GIT_DIR
=$
(git rev-parse
--git-dir)
11 if [ -z "$GIT_DIR" ]; then
12 echo >&2 "Not in a git checkout"
16 ## we walk the options to extract any ppg-commit options
17 ## any other option is passed on to git-commit
20 ## actually don't init the var, to avoid prepending
21 ## an empty string to the array
33 if [ -z "$myvar" ]; then
35 gitcommitargs
[${#gitcommitargs[@]}]="$1"
41 production_sha1
=$
(git rev-parse
--revs-only refs
/heads
/production
2>/dev
/null
)
42 orig_production_sha1
=$
(git rev-parse
--revs-only origin
/production \
45 if [ -n "$production_sha1" -a -n "$orig_production_sha1" ]; then
46 if [ "$production_sha1" != "$orig_production_sha1" ]; then
47 echo "Fast-forwarding local production head to match origin/production"
48 if ! git push .
$orig_production_sha1:refs
/heads
/production
; then
49 echo >&2 "ERROR: production and origin/production have diverged!"
55 if [ -n "$immediate" ]; then
56 # sanity-check we are on master
57 headname
=$
(git rev-parse
--symbolic-full-name --revs-only HEAD
)
58 if [ "$headname" != "refs/heads/master" ]; then
59 echo >&2 "ERROR: can only issue immediate commit on the master branch!"
64 $PPG_EXEC_PATH/ppg-validate-staged-files ||
exit 1
67 git commit
"${gitcommitargs[@]}" ||
exit 1
69 if [ -n "$immediate" ]; then
70 if [ -z "$production_sha1" ]; then
71 echo "Creating production branch"
72 git branch production master
73 production_sha1
=$
(git rev-parse
--revs-only production
)
75 if [[ $
(git log
--oneline production..HEAD|
wc -l) -gt 1 ]]; then
77 echo WARNING
: More than one change will be scheduled
for immediate
78 echo deployment. Please review the list of commits.
80 git log
--pretty=short
--stat production..HEAD
82 echo -n "Is this correct? [Ny] "
84 if [[ "${correct:0:1}" != 'Y' ]] && [[ "${correct:0:1}" != 'y' ]];
86 echo Cancelling immediate schedule.
90 if ! git push . HEAD
:refs
/heads
/production
; then
91 echo >&2 "ERROR: cannot fast-forward master to production"
92 echo >&2 " make sure the branches have not diverged"
96 echo "Immediate commit successful -- remember to git push --all"
97 echo "to publish the changes on the gold server."
99 echo 'Checking for scheduled updates to the production branch...'
100 $PPG_EXEC_PATH/ppg-update-production