4 # When tagging the candidate branch, and commit "A"
5 # has gone onto a topic branch that we previously
6 # merged, reject the tag.
8 # * -- * -- * -- A topic A
14 # We want to detect A when trying to tag candidate.
16 # This also implements candidate protection, e.g.
17 # only merges are allowed on candidate branches.
24 echo "updating $refname $oldrev $newrev"
29 # First make sure stable hasn't moved on us
30 baserev=$(git merge-base stable $newrev)
31 stablerev=$(git rev-parse stable)
32 if [ "$baserev" != "$stablerev" ] ; then
33 echo "----------------------------------------------------"
35 echo " Rejecting $refname because you need to merge:"
37 git rev-list "$baserev..$stablerev" | xargs git name-rev
39 echo "----------------------------------------------------"
43 # Now go back to stable and iterate through looking for commits on
44 # our merge parents that are not within us
45 git rev-list --first-parent "stable..$newrev" | while read commit ; do
46 number_of_parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | wc -l)
47 if [[ $number_of_parents > 1 ]] ; then
49 git rev-list --no-walk --parents $commit | sed 's/ /\n/g' | grep -v $commit | while read parent ; do
50 # Does this parent have any children besides us?
52 # List the parents of all branch commits (after stable/parent), find
53 # those that include our parent, get their sha1, remove our merge
54 git rev-list --parents --branches ^stable "^$parent" | grep $parent | gawk '{print $1}' | grep -v $commit | while read child ; do
55 number_missing=$(git rev-list "$child" "^$newrev" | wc -l)
56 if [[ $number_missing > 0 ]] ; then
57 echo "----------------------------------------------------"
59 echo " Rejecting $refname because you need to merge:"
61 git rev-list "$child" "^$newrev" | xargs git name-rev
63 echo "----------------------------------------------------"
68 # Find any commits in the parent (and another branch) but not us--that means we need it
69 # number_missing=$(git rev-list "$parent" --all "^$newrev" | wc -l)
70 # if [[ $number_missing > 0 ]] ; then
71 # echo "----------------------------------------------------"
73 # echo " Rejecting $refname because you need to merge:"
75 # git rev-list "$parent" --all "^$newrev" | xargs git name-rev
77 # echo "----------------------------------------------------"
87 refs/heads/candidate*)
88 # Look at commits between stable and us--ignoring those brought in by merges
89 git rev-list --first-parent "$newrev" ^stable | while read commit ; do
90 number_of_parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | wc -l)
91 if [[ $number_of_parents == 1 ]] ; then
92 echo "----------------------------------------------------"
94 echo " Candidate branches must be only merges"
96 echo "----------------------------------------------------"