diff options
author | Yun Mao <yunmao@gmail.com> | 2013-01-17 17:22:35 -0500 |
---|---|---|
committer | Yun Mao <yunmao@gmail.com> | 2013-01-17 18:01:43 -0500 |
commit | af5936f4aa55f751cee7648eaf4f156baa5868ea (patch) | |
tree | 05e2fd35b3a89496752fd142e0aa4625080f8955 | |
parent | 52fe25a5281a50a5e4c1ff093ce9ed966241a3d7 (diff) | |
download | nova-af5936f4aa55f751cee7648eaf4f156baa5868ea.tar.gz nova-af5936f4aa55f751cee7648eaf4f156baa5868ea.tar.xz nova-af5936f4aa55f751cee7648eaf4f156baa5868ea.zip |
Go back to the original branch after pylint check
Previously we save the current commit hash before running lintstack.
This is no problem for Jenkins but not very friendly if we run
lintstack locally. Every time after it's done, git is in detached
HEAD mode. This patch remembers the current branch name and
automatically go back to the branch if available. Otherwise we fall
back to the commit hash.
Part of blueprint lintstack
Change-Id: I145df3027022fc9a8302bc6da9ab300f677f3386
-rwxr-xr-x | tools/lintstack.sh | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/lintstack.sh b/tools/lintstack.sh index 42c6a60b3..d8591d03d 100755 --- a/tools/lintstack.sh +++ b/tools/lintstack.sh @@ -20,7 +20,16 @@ # commit for review. set -e TOOLS_DIR=$(cd $(dirname "$0") && pwd) -GITHEAD=`git rev-parse HEAD` +# Get the current branch name. +GITHEAD=`git rev-parse --abbrev-ref HEAD` +if [[ "$GITHEAD" == "HEAD" ]]; then + # In detached head mode, get revision number instead + GITHEAD=`git rev-parse HEAD` + echo "Currently we are at commit $GITHEAD" +else + echo "Currently we are at branch $GITHEAD" +fi + cp -f $TOOLS_DIR/lintstack.py $TOOLS_DIR/lintstack.head.py if git rev-parse HEAD^2 2>/dev/null; then @@ -47,8 +56,4 @@ git checkout $GITHEAD $TOOLS_DIR/lintstack.head.py echo "Check passed. FYI: the pylint exceptions are:" cat $TOOLS_DIR/pylint_exceptions -echo -echo "You are in detached HEAD mode. If you are a developer" -echo "and not very familiar with git, you might want to do" -echo "'git checkout branch-name' to go back to your branch." |