From c627f1fffbe0e4a190e3aad4770bc718951fc7cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 16 Jul 2019 17:09:53 +0900 Subject: [PATCH] Update install-githooks command (#5647) - Use NNFW_PROJECT_PATH instead of relative path - Check pre-push hook existance and update with backup or remove Signed-off-by: Hyeongseok Oh --- scripts/command/install-githooks | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/command/install-githooks b/scripts/command/install-githooks index 66c8535..053b526 100644 --- a/scripts/command/install-githooks +++ b/scripts/command/install-githooks @@ -1,11 +1,15 @@ #!/usr/bin/env bash -REPO_PATH=$(git rev-parse --show-toplevel) -REPO_HOOKS_PATH=infra/nnfw/git-hooks -GIT_HOOKS_PATH=$REPO_PATH/.git/hooks -REPO_PATH_REL=../../../ # Relative path from REPO_HOOKS_PATH +REPO_HOOKS_PATH=$NNFW_PROJECT_PATH/infra/nnfw/git-hooks +GIT_HOOKS_PATH=$NNFW_PROJECT_PATH/.git/hooks # Create symbolic links to hooks dir - -# NOTE `ln -s` does not overwrite if the file exists. -ln -s $REPO_PATH_REL/$REPO_HOOKS_PATH/pre-push.sh $GIT_HOOKS_PATH/pre-push +if [ -e $GIT_HOOKS_PATH/pre-push ]; then + echo "Backup old $GIT_HOOKS_PATH/pre-push to $GIT_HOOKS_PATH/pre-push~" + mv -v $GIT_HOOKS_PATH/pre-push $GIT_HOOKS_PATH/pre-push~ +elif [ -h $GIT_HOOKS_PATH/pre-push ]; then + ls -l $GIT_HOOKS_PATH/pre-push + echo "Remove broken symlink $GIT_HOOKS_PATH/pre-push" + rm -v $GIT_HOOKS_PATH/pre-push +fi +ln -sv $REPO_HOOKS_PATH/pre-push.sh $GIT_HOOKS_PATH/pre-push -- 2.7.4