From dc42a3f563ccaaed7489cf916e23094b8b16580e Mon Sep 17 00:00:00 2001 From: Anton Tsviatkou Date: Wed, 13 Jul 2016 22:21:56 -0700 Subject: [PATCH] Use HOMESHICK_CLONE_BRANCH env var to clone specific branch --- lib/commands/clone.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/commands/clone.sh b/lib/commands/clone.sh index f5ff5f55..1eaea39f 100644 --- a/lib/commands/clone.sh +++ b/lib/commands/clone.sh @@ -20,12 +20,18 @@ function clone { local git_out version_compare $GIT_VERSION 1.6.5 if [[ $? != 2 ]]; then - git_out=$(git clone --recursive "$git_repo" "$repo_path" 2>&1) + if [ -n "$HOMESHICK_CLONE_BRANCH" ];then + git_out=$(git clone -b "$HOMESHICK_CLONE_BRANCH" --recursive "$git_repo" "$repo_path" 2>&1) + else + git_out=$(git clone $clone_branch_param --recursive "$git_repo" "$repo_path" 2>&1) + fi; [[ $? == 0 ]] || err $EX_SOFTWARE "Unable to clone $git_repo. Git says:" "$git_out" success else git_out=$(git clone "$git_repo" "$repo_path" 2>&1) [[ $? == 0 ]] || err $EX_SOFTWARE "Unable to clone $git_repo. Git says:" "$git_out" + git_out=$(git branch "$HOMESHICK_CLONE_BRANCH" "origin/$HOMESHICK_CLONE_BRANCH" && git checkout "$HOMESHICK_CLONE_BRANCH") + [[ $? == 0 ]] || err $EX_SOFTWARE "Cannot checkout branch '$HOMESHICK_CLONE_BRANCH' for $git_repo. Git says:" "$git_out" success pending 'submodules' "$git_repo"