diff options
author | Sasha Levin <sasha.levin@oracle.com> | 2015-11-08 19:21:13 -0500 |
---|---|---|
committer | Sasha Levin <sasha.levin@oracle.com> | 2015-11-08 19:21:13 -0500 |
commit | 61874041d900a3297e017687aded7ed94b0be8f2 (patch) | |
tree | 921669e2fb2659d06e222e5409b0ab0b2e613c6c | |
parent | 67fb52f400c71345056349a6a957b938ce74b8f1 (diff) | |
download | stable-tools-61874041d900a3297e017687aded7ed94b0be8f2.tar.gz |
check_relevant: factor out check_relevant and use it in audit-range
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
-rw-r--r-- | common | 46 | ||||
-rwxr-xr-x | stable-audit-range | 73 | ||||
-rwxr-xr-x | stable-deps | 5 | ||||
-rwxr-xr-x | stable-steal-commits | 47 |
4 files changed, 93 insertions, 78 deletions
@@ -0,0 +1,46 @@ +#!/bin/bash + +function check_relevant { + cmt=$1 + maj=0 + min=0 + + # Let's grab the commit that this commit fixes (if exists (based on the "Fixes:" tag)). + fixescmt=`git log -1 $cmt | grep -i "fixes:" | head -n 1 | sed -e 's/^[ \t]*//' | cut -f 2 -d ':' | sed -e 's/^[ \t]*//' | cut -f 1 -d ' '` + + # If this commit fixes anything, but the broken commit isn't in our branch we don't + # need this commit either. + if [ "$fixescmt" != "" ] && [ "$(stable-commit-in-tree $fixescmt)" = "1" ]; then + return 0 + fi + + # Let's see if there's a version tag in this commit + full=$(git show $cmt | grep -i 'stable@vger') + full=$(echo ${full##* } | tr -cd '[[:digit:]]._-' | sed 's/]//g' | sed 's/\[//g' | sed 's/\./ /g') + + maj=$(echo $full | awk {"print \$1"}) + min=$(echo $full | awk {"print \$2"}) + + # Sanity check our extraction + if [ "$(echo ${full##* } | grep 'stable' | wc -l)" -gt "0" ]; then + return 1 + fi + + # Sanity check major version + if [ "$maj" != "2" ] && [ "$maj" != "3" ] && [ "$maj" != "4" ]; then + return 1 + fi + + # If the version tag is for a major version newer than ours + if [ "$STABLE_MAJ_VER" -lt "$maj" ]; then + return 1 + fi + + # Or if the overall version is newer than ours + if [ "$STABLE_MAJ_VER" -eq "$maj" ] && [ "$STABLE_MIN_VER" -lt "$min" ]; then + return 1 + fi + + # No version tag, unsure, or version tag is older than ours + return 0 +} diff --git a/stable-audit-range b/stable-audit-range index 5ef75db..b80852d 100755 --- a/stable-audit-range +++ b/stable-audit-range @@ -1,6 +1,14 @@ #!/bin/bash . show-missing-iter +. common + +function relevant { + check_relevant $1 + if [ $? -eq 0 ]; then + echo R + fi +} function applies { git cherry-pick $1 &> /dev/null @@ -13,49 +21,52 @@ function applies { fi } +function show_deps { + app=$1 + commit=$2 + + if [ "$app" = "-" ]; then + echo "Possible dependency chain:" + stable deps $commit 10 | sed 's/^/ /' + if [ $? -eq 1 ]; then + echo " "[...] + fi + fi +} + +function find_owning_branch { + subj=$(git log -1 --pretty="%s" $1) + for m in $OTHER_STABLE_TREES; do + if [ $(git log -F --grep "$subj" --format="%H" $m) ]; then + echo " "$m + fi + done +} + function handle_stable { others=$(stable find-alts $1) app=$(applies $1) + relevant=$(relevant $1) if [ "$others" != "" ]; then - printf "[E$app] %s\n" "$(git log -1 --oneline $1)" - subj=$(git log -1 --pretty="%s" $1) - for m in $OTHER_STABLE_TREES; do - if [ $(git log -F --grep "$subj" --format="%H" $m) ]; then - echo " "$m - fi - done - - if [ "$app" = "-" ]; then - echo "Possible dependency chain:" - stable deps $1 10 | sed 's/^/ /' - fi - echo "" + printf "[E$app$relevant] %s\n" "$(git log -1 --oneline $1)" + find_owning_branch $1 + show_deps $app $1 else - printf "[M$app] %s\n" "$(git log -1 --oneline $1)" - if [ "$app" = "-" ]; then - echo "Possible dependency chain:" - stable deps $1 10 | sed 's/^/ /' - echo - fi + printf "[M$app$relevant] %s\n" "$(git log -1 --oneline $1)" + show_deps $app $1 fi + echo } function handle_nonstable { others=$(stable find-alts $1) if [ "$others" != "" ]; then app=$(applies $1) - printf "[N$app] %s:\n" "$(git log -1 --oneline $1)" - subj=$(git log -1 --pretty="%s" $1) - for m in $OTHER_STABLE_TREES; do - if [ $(git log -F --grep "$subj" --format="%H" $m) ]; then - echo " "$m - fi - done - if [ "$app" = "-" ]; then - echo "Possible dependency chain:" - stable deps $1 10 | sed 's/^/ /' - fi - echo "" + relevant=$(relevant $1) + printf "[N$app$relevant] %s:\n" "$(git log -1 --oneline $1)" + find_owning_branch $1 + show_deps $app $1 + echo fi } diff --git a/stable-deps b/stable-deps index 2c2f846..db64328 100755 --- a/stable-deps +++ b/stable-deps @@ -8,13 +8,13 @@ if [ $# -ne 1 ] && [ $# -ne 2 ]; then echo "Usage: stable deps <commit sha1> [Max deps to show]" exit 1 fi -set -x + maxdeps=$2 function handle_one { ((maxdeps--)) if [ $maxdeps -eq 0 ]; then - exit + exit 1 fi stable commit-in-tree $1 @@ -29,3 +29,4 @@ function handle_one { } handle_one $1 +exit 0 diff --git a/stable-steal-commits b/stable-steal-commits index 583e9ac..9fa2a15 100755 --- a/stable-steal-commits +++ b/stable-steal-commits @@ -4,6 +4,8 @@ # backports if required. # +. common + function pick_one { # Let's try cherry-picking the given commit first. @@ -28,51 +30,6 @@ function pick_one { return $? } -function check_relevant { - cmt=$1 - maj=0 - min=0 - - # Let's grab the commit that this commit fixes (if exists (based on the "Fixes:" tag)). - fixescmt=`git show $cmt | grep -i "fixes:" | head -n 1 | sed -e 's/^[ \t]*//' | cut -f 2 -d ':' | sed -e 's/^[ \t]*//' | cut -f 1 -d ' '` - - # If this commit fixes anything, but the broken commit isn't in our branch we don't - # need this commit either. - if [ "$fixescmt" != "" ] && [ "$(stable-commit-in-tree $fixescmt)" = "1" ]; then - return 0 - fi - - # Let's see if there's a version tag in this commit - full=$(git show $cmt | grep -i 'stable@vger') - full=$(echo ${full##* } | tr -cd '[[:digit:]]._-' | sed 's/]//g' | sed 's/\[//g' | sed 's/\./ /g') - - maj=$(echo $full | awk {"print \$1"}) - min=$(echo $full | awk {"print \$2"}) - - # Sanity check our extraction - if [ "$(echo ${full##* } | grep 'stable' | wc -l)" -gt "0" ]; then - return 1 - fi - - # Sanity check major version - if [ "$maj" != "2" ] && [ "$maj" != "3" ] && [ "$maj" != "4" ]; then - return 1 - fi - - # If the version tag is for a major version newer than ours - if [ "STABLE_MAJ_VER" -gt "$maj" ]; then - return 1 - fi - - # Or if the overall version is newer than ours - if [ "STABLE_MAJ_VER" -eq "$maj" ] && [ "STABLE_MIN_VER" -ge "$min" ]; then - return 1 - fi - - # No version tag, unsure, or version tag is older than ours - return 0 -} - function do_one { for i in $(git log --no-merges --format="%H" $1 $2 | tac); do subj=$(git log -1 --format="%s" $i) |