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 production_sha1
=$
(git rev-parse
--revs-only refs
/heads
/production
2>/dev
/null
)
17 if [ -z "$production_sha1" ]; then
18 # no production branch, nothing to do
22 orig_production_sha1
=$
(git rev-parse
--revs-only origin
/production
)
24 target_sha1
=$orig_production_sha1
26 nowepoch
=$
(date --utc +%s
)
27 for tag
in $
(git tag
-l |
grep '^ppg-sched-' |
sort -r); do
28 # Sneaky sed: 's/-/ /3g' replaces the 3rd dash only
29 datestamp
=$
(echo "$tag"|
sed 's/^ppg-sched-//;s/-/ /3g;s/\./:/g;')
30 tagepoch
=$
(date -d "$datestamp" +%s
)
31 if [[ $tagepoch -lt $nowepoch ]]; then
36 if [ -n "$targettag" ]; then
37 target_sha1
=$
(git rev-parse
--revs-only ${targettag}^
{commit
} ) ||
exit 1
39 # perhaps origin/production is ahead of scheduled tags,
42 if [ -n "$orig_production_sha1" ]; then
43 if $PPG_EXEC_PATH/ppg-is-ancestor
$targettag $orig_production_sha1 ; then
44 target_sha1
=$orig_production_sha1
49 if [ "$production_sha1" = "$target_sha1" ]; then
54 if ! $PPG_EXEC_PATH/ppg-is-ancestor
$production_sha1 $target_sha1 ; then
55 echo "ERROR: production branch and $targettag have diverged!"
59 headname
=$
(git rev-parse
--symbolic-full-name --revs-only HEAD
)
61 if [ "$headname" = 'refs/heads/production' ]; then
62 # sanity checks when on production
63 if [ $
(git
diff --name-status HEAD |
wc -l) -gt 0 ]; then
64 echo >&2 'ERROR: Currently on "production" branch and with dirty state.'
65 echo >&2 " Refusing to update with scheduled changes."
70 echo "About to update production with scheduled changes:"
71 git
--no-pager log
--oneline -n 100 refs
/heads
/production..
$target_sha1
74 if [ "$headname" = 'refs/heads/production' ]; then
75 echo "Updating current production checkout"
76 git merge
--ff-only $target_sha1
79 git push .
$target_sha1:refs
/heads
/production