From c014283ed4dcc6a7d24a9656802b8a23e8106574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20Kalmo?= Date: Sat, 25 Mar 2017 11:07:33 +0200 Subject: [PATCH] fixed checkout scripts --- checkout.bat | 42 ++++++++++++++++++++++++++++++++++++++---- checkout.sh | 28 ++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/checkout.bat b/checkout.bat index 7639169..504cef6 100644 --- a/checkout.bat +++ b/checkout.bat @@ -1,11 +1,45 @@ +echo off -git clone https://bitbucket.org/%1/i399 .\.tmp +set USER=%1 +set TAG=%2 +set TMP=./.tmp +set SUB_DIR= -cd .\.tmp +if "%1" == "" ( + echo Usage: %0 user_name tag + exit /b 1 +) -git checkout %2 +if "%TAG%" == "hw3" ( + echo hw3 not implemented yet + exit /b 1 +) -if %errorlevel% neq 0 exit /b %errorlevel% +if "%TAG%" == "hw4" ( + echo hw4 not implemented yet + exit /b 1 +) + +if "%TAG%" == "hw2" ( + set SUB_DIR=ng1 +) + +if "%SUB_DIR%" == "" ( + echo unknown tag + exit /b 1 +) + +git clone https://bitbucket.org/%USER%/i399 %TMP% + +if %errorlevel% neq 0 exit /b 1 + +cd %TMP% + +git checkout %TAG% + +if %errorlevel% neq 0 exit /b 1 + +cd %SUB_DIR% call npm install diff --git a/checkout.sh b/checkout.sh index 3055737..8524c3f 100755 --- a/checkout.sh +++ b/checkout.sh @@ -2,6 +2,30 @@ set -e -git clone https://bitbucket.org/$1/i399 ./.tmp +USER=$1 +TAG=$2 +TMP="./.tmp" +SUB_DIR="" -(cd ./.tmp && git checkout $2 && npm install && npm start) +if [ $# -eq 0 ];then + echo "Usage: $0 " + exit 1 +fi + +if [ $TAG == "hw3" ] || [ $TAG == "hw4" ]; then + echo 'not implemented yet' + exit 1 +fi + +if [ $TAG == "hw2" ]; then + SUB_DIR="ng1" +fi + +if [ -z $SUB_DIR ]; then + echo 'unknown tag' + exit 1 +fi + +git clone https://bitbucket.org/$USER/i399 $TMP + +(cd "$TMP" && git checkout $TAG && cd "$SUB_DIR" && npm install && npm start)