3 PPG_EXEC_PATH
=$
( dirname $
(realpath
"${BASH_SOURCE[0]}" ) )
4 GIT_EXEC_PATH
=$
(git
--exec-path)
5 GIT_DIR
=$
(git rev-parse
--git-dir)
7 if [ -z "$GIT_DIR" ]; then
8 echo >&2 "Not in a git checkout"
12 headname
=$
(git rev-parse
--symbolic-full-name --revs-only HEAD
)
14 if [[ "$headname" != "refs/heads/production" ]]; then
15 echo >&2 "WARNING: Not on production branch"
18 initial_sha1
=$
(git rev-parse
--revs-only HEAD
)
19 lastgood_sha1
=$
(git rev-parse
--revs-only refs
/heads
/ppg
/lastgood
)
21 # resilient wrt server availability...
22 git fetch ||
echo "WARNING: error in git fetch"
24 if [[ "$headname" = "refs/heads/production" ]]; then
25 $PPG_EXEC_PATH/ppg-update-production ||
exit 1
27 if ! git merge
--ff-only ; then
28 echo "ERROR: Failed to auto-merge with ff-only,"
29 echo " perhaps the current branch needs to"
30 echo " track a remote branch or you have dirty state."
31 echo " You can merge by hand and use ppg-apply"
35 uptodate_sha1
=$
(git rev-parse
--revs-only HEAD
)
37 if [[ "$uptodate_sha1" = "$lastgood_sha1" ]]; then
42 echo "Executing command"
44 echo " "ppg-apply
"$@"
46 echo "Log of changes to apply"
48 if [ -n "$lastgood_sha1" ]; then
49 git log
--oneline ${lastgood_sha1}..
${uptodate_sha1}
51 git log
--oneline ${uptodate_sha1}
54 exec $PPG_EXEC_PATH/ppg-apply
"$@"