From 11e1c4c558edfdd7a6272f0450a80c5b24d7d9a9 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 7 Aug 2012 09:06:51 -0500 Subject: [PATCH] Prevent unnecessary git fetch calls. Change-Id: I89df9f5491cc8fc49386e5f1496a9be51b443268 Reviewed-on: https://review.openstack.org/10959 Approved: Monty Taylor Reviewed-by: Monty Taylor Tested-by: Jenkins --- install_modules.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install_modules.sh b/install_modules.sh index ab2128d50f..c31f5477c5 100644 --- a/install_modules.sh +++ b/install_modules.sh @@ -13,9 +13,13 @@ function clone_git() { if [ ! -d $MODULE_PATH/$REPO ] ; then git clone $REMOTE_URL $MODULE_PATH/$REPO fi - (cd $MODULE_PATH/$REPO && - git fetch origin && - git reset --hard $REV >/dev/null ) + OLDDIR=`pwd` + cd $MODULE_PATH/$REPO + if ! git rev-parse HEAD | grep "^$REV" >/dev/null; then + git fetch origin + git reset --hard $REV >/dev/null + fi + cd $OLDDIR } if ! puppet help module >/dev/null 2>&1 ; then