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.
43 if expr "$oldrev" : '0*$' >/dev/null ; then
47 if [ "$refname" != "refs/heads/stable" ] ; then
52 # - all commits from old..new
53 # - unless they were already pointed to by a branch
54 # = all new commits on stable
55 count=$(git rev-parse --not --branches | git rev-list --stdin $oldrev..$newrev | wc -l)
56 if [ "$count" -ne "1" ] ; then
57 echo "----------------------------------------------------"
59 echo "Moving stable must entail a single commit"
61 echo "----------------------------------------------------"
65 number_of_parents=$(git rev-list --no-walk --parents $newrev | sed 's/ /\n/g' | grep -v $newrev | wc -l)
66 if [ "$number_of_parents" -ne "2" ] ; then
67 echo "----------------------------------------------------"
69 echo "Moving stable must entail a merge commit"
71 echo "----------------------------------------------------"
75 first_parent=$(git rev-list --no-walk --parents $newrev | sed 's/ /\n/g' | grep -v $newrev | head --lines=1)
76 if [ "$first_parent" != "$oldrev" ] ; then
77 echo "----------------------------------------------------"
79 echo "Moving stable must have the previous stable as the first parent"
81 echo "----------------------------------------------------"
85 second_parent=$(git rev-list --no-walk --parents $newrev | sed 's/ /\n/g' | grep -v $newrev | tail --lines=1)
86 changed_lines=$(git diff $second_parent..$newrev | wc -l)
87 if [ "$changed_lines" -ne "0" ] ; then
88 echo "----------------------------------------------------"
90 echo "Moving stable must not result in any changes from $second_parent"
92 echo "----------------------------------------------------"