Clone of mesa.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

get-pick-list.sh 3.5KB

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