3 if [[ -n "${PPG_DEBUG}" ]]; then
7 pushd /etc
/puppet
>/dev
/null ||
exit 1
9 PPG_EXEC_PATH
=$
( dirname $
(readlink
-f "${BASH_SOURCE[0]}" ) )
10 GIT_EXEC_PATH
=$
(git
--exec-path)
11 GIT_DIR
=$
(git rev-parse
--git-dir)
12 GIT_SSH
="${PPG_EXEC_PATH}/ppg-ssh"
14 if [ -z "$GIT_DIR" ]; then
15 echo >&2 "Not in a git checkout"
19 headname
=$
(git rev-parse
--symbolic-full-name --revs-only HEAD
)
21 if [[ "$headname" != "refs/heads/production" ]]; then
22 echo >&2 "WARNING: Not on production branch"
25 initial_sha1
=$
(git rev-parse
--revs-only HEAD
)
26 lastgood_sha1
=$
(git rev-parse
--revs-only refs
/heads
/ppg
/lastgood
)
28 # resilient wrt server availability...
29 git fetch ||
echo "WARNING: error in git fetch"
31 if [[ "$headname" = "refs/heads/production" ]]; then
32 $PPG_EXEC_PATH/ppg-update-production ||
exit 1
34 if ! git merge
--ff-only ; then
35 echo "ERROR: Failed to auto-merge with ff-only,"
36 echo " perhaps the current branch needs to"
37 echo " track a remote branch or you have dirty state."
38 echo " You can merge by hand and use ppg-apply"
42 uptodate_sha1
=$
(git rev-parse
--revs-only HEAD
)
44 echo "Executing command"
46 echo " "ppg-apply
"$@"
48 echo "Log of changes to apply"
50 if [ -n "$lastgood_sha1" ]; then
51 if [[ "$uptodate_sha1" != "$lastgood_sha1" ]]; then
52 git log
--oneline ${lastgood_sha1}..
${uptodate_sha1}
54 echo "No changes in git"
55 ## we could allow optional lazy runs
57 # echo "lazy run, exiting"
62 git log
--oneline ${uptodate_sha1}
65 exec $PPG_EXEC_PATH/ppg-apply
"$@"