diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-01-12 10:13:33 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-01-12 10:13:33 +0000 |
| commit | f8ce2143ba12b1e39246e35a3e28d7060e110583 (patch) | |
| tree | 9df04682eb9e58635750785168d3e6726d72e401 | |
| parent | d6b41ffd411eab94c0beb531077c5a6abed63c49 (diff) | |
| parent | 477722a849ce801cfdb150a8da94e713f2779846 (diff) | |
Merge "Fix lintstack check for multi-patch reviews"
| -rwxr-xr-x | tools/lintstack.sh | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tools/lintstack.sh b/tools/lintstack.sh index 848a16fa5..42c6a60b3 100755 --- a/tools/lintstack.sh +++ b/tools/lintstack.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2012, AT&T Labs, Yun Mao <yunmao@gmail.com> +# Copyright (c) 2012-2013, AT&T Labs, Yun Mao <yunmao@gmail.com> # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -15,13 +15,31 @@ # License for the specific language governing permissions and limitations # under the License. -# Use lintstack.py to compare pylint errors between HEAD and HEAD~1 - +# Use lintstack.py to compare pylint errors. +# We run pylint twice, once on HEAD, once on the code before the latest +# commit for review. set -e TOOLS_DIR=$(cd $(dirname "$0") && pwd) GITHEAD=`git rev-parse HEAD` cp -f $TOOLS_DIR/lintstack.py $TOOLS_DIR/lintstack.head.py -git checkout HEAD~1 + +if git rev-parse HEAD^2 2>/dev/null; then + # The HEAD is a Merge commit. Here, the patch to review is + # HEAD^2, the master branch is at HEAD^1, and the patch was + # written based on HEAD^2~1. + PREV_COMMIT=`git rev-parse HEAD^2~1` + git checkout HEAD~1 + # The git merge is necessary for reviews with a series of patches. + # If not, this is a no-op so won't hurt either. + git merge $PREV_COMMIT +else + # The HEAD is not a merge commit. This won't happen on gerrit. + # Most likely you are running against your own patch locally. + # We assume the patch to examine is HEAD, and we compare it against + # HEAD~1 + git checkout HEAD~1 +fi + # First generate tools/pylint_exceptions from HEAD~1 $TOOLS_DIR/lintstack.head.py generate # Then use that as a reference to compare against HEAD |
