trim-reports: fix up repack call
[puppet-git.git] / ppg-pullapply
blob75821f1cef28431a580617cdaea277769ce2edaf
1 #!/bin/bash
3 if [[ -n "${PPG_DEBUG}" ]]; then
4 set -x
5 fi
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"
16 exit 1
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
33 else
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"
45 echo
46 echo " "ppg-apply "$@"
47 echo
48 echo "Log of changes to apply"
49 echo
50 if [ -n "$lastgood_sha1" ]; then
51 if [[ "$uptodate_sha1" != "$lastgood_sha1" ]]; then
52 git log --oneline ${lastgood_sha1}..${uptodate_sha1}
53 else
54 echo "No changes in git"
55 ## we could allow optional lazy runs
56 # if [ opt ]; then
57 # echo "lazy run, exiting"
58 # exit 0
59 # fi
61 else
62 git log --oneline ${uptodate_sha1}
64 echo
65 exec $PPG_EXEC_PATH/ppg-apply "$@"