4 # This enforces stable only moving in the approved way, which
5 # is via empty (no change) merge commits. The rationale is that
6 # in the DAG we want a simple, one-commit move from each release
13 # \ * -- * -- B topic1
17 # And then publishing stable was a matter of fast-forwarding
20 # In a complicated (non-rebased) DAG, this becomes hard to follow,
21 # so want we want instead is:
23 # * -- A ----------- C stable
25 # \ * -- * -- B topic1
29 # Where commit C lists as it's first parent the prior stable
30 # commit and as it's second parent the release candidate. No
31 # other parents are allowed (e.g. no octopus merges here, which
32 # would insinuate qa didn't happen on the merged result).
34 # Also, we want to enforce that C does not actually introduce
35 # any diffs to the files between B and C--otherwise this changes
36 # would not have appeared in QA.
44 if expr "$oldrev" : '0*$' >/dev/null ; then
48 if [ "$refname" != "refs/heads/stable" ] ; then
53 # - all commits from old..new
54 # - unless they were already pointed to by a branch
55 # = all new commits on stable
56 count=$(git rev-parse --not --branches | git rev-list --stdin $oldrev..$newrev | wc -l)
57 if [ "$count" -ne "1" ] ; then
58 echo "----------------------------------------------------"
60 echo "Moving stable must entail a single commit"
62 echo "----------------------------------------------------"
66 number_of_parents=$(git rev-list --no-walk --parents $newrev | sed 's/ /\n/g' | grep -v $newrev | wc -l)
67 if [ "$number_of_parents" -ne "2" ] ; then
68 echo "----------------------------------------------------"
70 echo "Moving stable must entail a merge commit"
72 echo "----------------------------------------------------"
76 first_parent=$(git rev-list --no-walk --parents $newrev | sed 's/ /\n/g' | grep -v $newrev | head --lines=1)
77 if [ "$first_parent" != "$oldrev" ] ; then
78 echo "----------------------------------------------------"
80 echo "Moving stable must have the previous stable as the first parent"
82 echo "----------------------------------------------------"
86 second_parent=$(git rev-list --no-walk --parents $newrev | sed 's/ /\n/g' | grep -v $newrev | tail --lines=1)
87 changed_lines=$(git diff $second_parent..$newrev | wc -l)
88 if [ "$changed_lines" -ne "0" ] ; then
89 echo "----------------------------------------------------"
91 echo "Moving stable must not result in any changes"
93 echo "----------------------------------------------------"