Skip to content

Commit

Permalink
Do a check for HOMESHICK_CLONE_BRANCH before checking out a branch
Browse files Browse the repository at this point in the history
  • Loading branch information
antontsv committed Aug 26, 2016
1 parent 8a5deea commit 9a0d420
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/commands/clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ function clone {
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)
git_out=$(git clone --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"
if [ -n "$HOMESHICK_CLONE_BRANCH" ];then
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"
fi;
success

pending 'submodules' "$git_repo"
Expand Down

0 comments on commit 9a0d420

Please sign in to comment.