Ian Romanick | 2d95db6 | 2012-10-19 22:30:53 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Andreas Boll | fa27a0d | 2012-10-19 22:54:56 +0200 | [diff] [blame] | 3 | # Script for generating a list of candidates for cherry-picking to a stable branch |
Andreas Boll | b8e41db | 2013-04-18 09:32:39 +0200 | [diff] [blame] | 4 | # |
| 5 | # Usage examples: |
| 6 | # |
| 7 | # $ bin/get-pick-list.sh |
| 8 | # $ bin/get-pick-list.sh > picklist |
| 9 | # $ bin/get-pick-list.sh | tee picklist |
Emil Velikov | fac1016 | 2018-11-08 15:05:14 +0000 | [diff] [blame] | 10 | # |
| 11 | # The output is as follows: |
| 12 | # [nomination_type] commit_sha commit summary |
| 13 | |
| 14 | is_stable_nomination() |
| 15 | { |
Dylan Baker | aff52dd | 2019-02-12 14:03:21 -0800 | [diff] [blame] | 16 | git show --pretty=medium --summary "$1" | grep -q -i -o "CC:.*mesa-stable" |
Emil Velikov | fac1016 | 2018-11-08 15:05:14 +0000 | [diff] [blame] | 17 | } |
Andreas Boll | fa27a0d | 2012-10-19 22:54:56 +0200 | [diff] [blame] | 18 | |
Emil Velikov | e6b3a3b | 2018-11-08 15:05:15 +0000 | [diff] [blame] | 19 | is_typod_nomination() |
| 20 | { |
Dylan Baker | aff52dd | 2019-02-12 14:03:21 -0800 | [diff] [blame] | 21 | git show --pretty=medium --summary "$1" | grep -q -i -o "CC:.*mesa-dev" |
Emil Velikov | e6b3a3b | 2018-11-08 15:05:15 +0000 | [diff] [blame] | 22 | } |
| 23 | |
Emil Velikov | 6b296f6 | 2018-12-17 15:44:25 +0000 | [diff] [blame] | 24 | fixes= |
| 25 | |
Emil Velikov | b7418d1 | 2018-11-08 15:05:18 +0000 | [diff] [blame] | 26 | # Helper to handle various mistypos of the fixes tag. |
| 27 | # The tag string itself is passed as argument and normalised within. |
Emil Velikov | 6b296f6 | 2018-12-17 15:44:25 +0000 | [diff] [blame] | 28 | # |
| 29 | # Resulting string in the global variable "fixes" and contains entries |
| 30 | # in the form "fixes:$sha" |
Emil Velikov | b7418d1 | 2018-11-08 15:05:18 +0000 | [diff] [blame] | 31 | is_sha_nomination() |
Emil Velikov | 181203f | 2018-11-08 15:05:16 +0000 | [diff] [blame] | 32 | { |
| 33 | fixes=`git show --pretty=medium -s $1 | tr -d "\n" | \ |
Emil Velikov | b7418d1 | 2018-11-08 15:05:18 +0000 | [diff] [blame] | 34 | sed -e 's/'"$2"'/\nfixes:/Ig' | \ |
Juan A. Suarez Romero | b3c25e6 | 2019-09-10 10:30:43 +0200 | [diff] [blame] | 35 | grep -Eo 'fixes:[a-f0-9]{4,40}'` |
Emil Velikov | 181203f | 2018-11-08 15:05:16 +0000 | [diff] [blame] | 36 | |
Emil Velikov | 6b296f6 | 2018-12-17 15:44:25 +0000 | [diff] [blame] | 37 | fixes_count=`echo "$fixes" | grep "fixes:" | wc -l` |
Emil Velikov | c0012a0 | 2018-11-08 15:05:21 +0000 | [diff] [blame] | 38 | if test $fixes_count -eq 0; then |
Emil Velikov | 6b296f6 | 2018-12-17 15:44:25 +0000 | [diff] [blame] | 39 | return 1 |
Emil Velikov | 181203f | 2018-11-08 15:05:16 +0000 | [diff] [blame] | 40 | fi |
Emil Velikov | e0dbfc9 | 2018-12-17 16:25:40 +0000 | [diff] [blame] | 41 | |
| 42 | # Throw a warning for each invalid sha |
| 43 | while test $fixes_count -gt 0; do |
| 44 | # Treat only the current line |
| 45 | id=`echo "$fixes" | tail -n $fixes_count | head -n 1 | cut -d : -f 2` |
| 46 | fixes_count=$(($fixes_count-1)) |
Andres Gomez | 3ec9ab8 | 2019-01-11 16:43:27 +0200 | [diff] [blame] | 47 | if ! git show $id >/dev/null 2>&1; then |
Emil Velikov | e0dbfc9 | 2018-12-17 16:25:40 +0000 | [diff] [blame] | 48 | echo WARNING: Commit $1 lists invalid sha $id |
| 49 | fi |
| 50 | done |
| 51 | |
Emil Velikov | 6b296f6 | 2018-12-17 15:44:25 +0000 | [diff] [blame] | 52 | return 0 |
| 53 | } |
| 54 | |
| 55 | # Checks if at least one of offending commits, listed in the global |
| 56 | # "fixes", is in branch. |
| 57 | sha_in_range() |
| 58 | { |
| 59 | fixes_count=`echo "$fixes" | grep "fixes:" | wc -l` |
Emil Velikov | c0012a0 | 2018-11-08 15:05:21 +0000 | [diff] [blame] | 60 | while test $fixes_count -gt 0; do |
Emil Velikov | 181203f | 2018-11-08 15:05:16 +0000 | [diff] [blame] | 61 | # Treat only the current line |
| 62 | id=`echo "$fixes" | tail -n $fixes_count | head -n 1 | cut -d : -f 2` |
| 63 | fixes_count=$(($fixes_count-1)) |
| 64 | |
Emil Velikov | 181203f | 2018-11-08 15:05:16 +0000 | [diff] [blame] | 65 | # Be that cherry-picked ... |
| 66 | # ... or landed before the branchpoint. |
| 67 | if grep -q ^$id already_picked || |
| 68 | grep -q ^$id already_landed ; then |
| 69 | return 0 |
| 70 | fi |
| 71 | done |
| 72 | return 1 |
| 73 | } |
| 74 | |
Emil Velikov | b7418d1 | 2018-11-08 15:05:18 +0000 | [diff] [blame] | 75 | is_fixes_nomination() |
| 76 | { |
| 77 | is_sha_nomination "$1" "fixes:[[:space:]]*" |
Emil Velikov | 209525a | 2018-11-08 15:05:19 +0000 | [diff] [blame] | 78 | if test $? -eq 0; then |
| 79 | return 0 |
| 80 | fi |
| 81 | is_sha_nomination "$1" "fixes[[:space:]]\+" |
Emil Velikov | b7418d1 | 2018-11-08 15:05:18 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Emil Velikov | 77ff0bf | 2018-11-08 15:05:20 +0000 | [diff] [blame] | 84 | is_brokenby_nomination() |
| 85 | { |
| 86 | is_sha_nomination "$1" "broken by" |
| 87 | } |
| 88 | |
Emil Velikov | adbdfc6 | 2018-11-14 18:49:54 +0000 | [diff] [blame] | 89 | is_revert_nomination() |
| 90 | { |
| 91 | is_sha_nomination "$1" "This reverts commit " |
| 92 | } |
| 93 | |
Emil Velikov | d6b1d11 | 2017-02-13 00:37:03 +0000 | [diff] [blame] | 94 | # Use the last branchpoint as our limit for the search |
| 95 | latest_branchpoint=`git merge-base origin/master HEAD` |
| 96 | |
Emil Velikov | 181203f | 2018-11-08 15:05:16 +0000 | [diff] [blame] | 97 | # List all the commits between day 1 and the branch point... |
| 98 | git log --reverse --pretty=%H $latest_branchpoint > already_landed |
| 99 | |
| 100 | # ... and the ones cherry-picked. |
Dylan Baker | c8acfd5 | 2018-05-21 10:30:42 -0700 | [diff] [blame] | 101 | git log --reverse --pretty=medium --grep="cherry picked from commit" $latest_branchpoint..HEAD |\ |
Andreas Boll | 135ec3a | 2012-10-19 23:13:12 +0200 | [diff] [blame] | 102 | grep "cherry picked from commit" |\ |
| 103 | sed -e 's/^[[:space:]]*(cherry picked from commit[[:space:]]*//' -e 's/)//' > already_picked |
| 104 | |
Emil Velikov | 181203f | 2018-11-08 15:05:16 +0000 | [diff] [blame] | 105 | # Grep for potential candidates |
Emil Velikov | adbdfc6 | 2018-11-14 18:49:54 +0000 | [diff] [blame] | 106 | git log --reverse --pretty=%H -i --grep='^CC:.*mesa-stable\|^CC:.*mesa-dev\|\<fixes\>\|\<broken by\>\|This reverts commit' $latest_branchpoint..origin/master |\ |
Ian Romanick | 2d95db6 | 2012-10-19 22:30:53 +0200 | [diff] [blame] | 107 | while read sha |
| 108 | do |
Andreas Boll | 3e3ff4c | 2012-10-20 21:50:30 +0200 | [diff] [blame] | 109 | # Check to see whether the patch is on the ignore list. |
Emil Velikov | c0012a0 | 2018-11-08 15:05:21 +0000 | [diff] [blame] | 110 | if test -f bin/.cherry-ignore; then |
Andreas Boll | ca89886 | 2012-10-22 21:18:17 +0200 | [diff] [blame] | 111 | if grep -q ^$sha bin/.cherry-ignore ; then |
Andreas Boll | 3e3ff4c | 2012-10-20 21:50:30 +0200 | [diff] [blame] | 112 | continue |
| 113 | fi |
Ian Romanick | 2d95db6 | 2012-10-19 22:30:53 +0200 | [diff] [blame] | 114 | fi |
| 115 | |
| 116 | # Check to see if it has already been picked over. |
Andreas Boll | 135ec3a | 2012-10-19 23:13:12 +0200 | [diff] [blame] | 117 | if grep -q ^$sha already_picked ; then |
| 118 | continue |
Ian Romanick | 2d95db6 | 2012-10-19 22:30:53 +0200 | [diff] [blame] | 119 | fi |
| 120 | |
Emil Velikov | 6b296f6 | 2018-12-17 15:44:25 +0000 | [diff] [blame] | 121 | if is_fixes_nomination "$sha"; then |
Emil Velikov | 181203f | 2018-11-08 15:05:16 +0000 | [diff] [blame] | 122 | tag=fixes |
Emil Velikov | 77ff0bf | 2018-11-08 15:05:20 +0000 | [diff] [blame] | 123 | elif is_brokenby_nomination "$sha"; then |
| 124 | tag=brokenby |
Emil Velikov | adbdfc6 | 2018-11-14 18:49:54 +0000 | [diff] [blame] | 125 | elif is_revert_nomination "$sha"; then |
| 126 | tag=revert |
Emil Velikov | 6b296f6 | 2018-12-17 15:44:25 +0000 | [diff] [blame] | 127 | elif is_stable_nomination "$sha"; then |
| 128 | tag=stable |
| 129 | elif is_typod_nomination "$sha"; then |
| 130 | tag=typod |
Emil Velikov | fac1016 | 2018-11-08 15:05:14 +0000 | [diff] [blame] | 131 | else |
| 132 | continue |
| 133 | fi |
| 134 | |
Emil Velikov | 6b296f6 | 2018-12-17 15:44:25 +0000 | [diff] [blame] | 135 | case "$tag" in |
| 136 | fixes | brokenby | revert ) |
| 137 | if ! sha_in_range; then |
| 138 | continue |
| 139 | fi |
| 140 | ;; |
| 141 | * ) |
| 142 | ;; |
| 143 | esac |
| 144 | |
Emil Velikov | fac1016 | 2018-11-08 15:05:14 +0000 | [diff] [blame] | 145 | printf "[ %8s ] " "$tag" |
Dylan Baker | 6086138 | 2019-09-23 11:05:16 -0700 | [diff] [blame] | 146 | git --no-pager show --no-patch --pretty=oneline $sha |
Ian Romanick | 2d95db6 | 2012-10-19 22:30:53 +0200 | [diff] [blame] | 147 | done |
Andreas Boll | 135ec3a | 2012-10-19 23:13:12 +0200 | [diff] [blame] | 148 | |
| 149 | rm -f already_picked |
Emil Velikov | 181203f | 2018-11-08 15:05:16 +0000 | [diff] [blame] | 150 | rm -f already_landed |