From e6b368f807d75a7868e324bafbcf403989dff16d Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Wed, 9 Apr 2014 09:47:36 +0800 Subject: [PATCH] enhanced compare-with-develop-style.sh script --- cq-configs/checkstyle/checkstyle.xml | 10 +++++++++- tools/compare-with-develop-style.sh | 12 +++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cq-configs/checkstyle/checkstyle.xml b/cq-configs/checkstyle/checkstyle.xml index 06539c74110b..cbaf7fe1d222 100644 --- a/cq-configs/checkstyle/checkstyle.xml +++ b/cq-configs/checkstyle/checkstyle.xml @@ -38,7 +38,7 @@ - + @@ -58,6 +58,12 @@ + + + + + + @@ -212,6 +218,8 @@ + + diff --git a/tools/compare-with-develop-style.sh b/tools/compare-with-develop-style.sh index f9464da59959..02fafeb3953a 100755 --- a/tools/compare-with-develop-style.sh +++ b/tools/compare-with-develop-style.sh @@ -1,5 +1,8 @@ #!/bin/sh +CONFIG_FILE=cq-configs/checkstyle/checkstyle.xml +cp $CONFIG_FILE /tmp/checkstyle.xml + if [ x"$1" == x ]; then compared_branch=develop fi @@ -12,13 +15,13 @@ current_branch_filtered=$(echo $current_branch | tr "/" "-") modified_files=$(git --no-pager diff develop --name-only | grep ".java$") # Check style on current branch -checkstyle -c cq-configs/checkstyle/checkstyle.xml $modified_files > /tmp/checkstyle-$current_branch_filtered.log +checkstyle -c /tmp/checkstyle.xml $modified_files | sed "s/:[0-9]*//g" > /tmp/checkstyle-$current_branch_filtered.log # Check style on current develop git stash | grep "No local changes to save" > /dev/null needpop=$? git checkout $compared_branch -checkstyle -c cq-configs/checkstyle/checkstyle.xml $modified_files > /tmp/checkstyle-develop.log +checkstyle -c /tmp/checkstyle.xml $modified_files | sed "s/:[0-9]*//g" > /tmp/checkstyle-develop.log # Back on current branch git checkout $current_branch @@ -26,7 +29,10 @@ git checkout $current_branch echo echo -------------------------- echo The following warnings seem to be introduced by your branch: -diff -u /tmp/checkstyle-develop.log /tmp/checkstyle-$current_branch_filtered.log | grep "^+" | grep -v "^+++" +diff -u /tmp/checkstyle-develop.log /tmp/checkstyle-$current_branch_filtered.log > /tmp/checkstyle.diff +cat /tmp/checkstyle.diff | grep "^+" | grep -v "^+++" || echo Yay no new style errors!! +echo Style errors removed: +cat /tmp/checkstyle.diff | grep "^-" | wc -l # restore local changes if [ $needpop -eq 1 ]; then