Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress git error messages when checking out master after cloning #32

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/whiskey_disk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ def if_task_defined(task, cmd)
end

def safe_branch_checkout(path, my_branch)
%Q(cd #{path} && git checkout -b #{my_branch} origin/#{my_branch} || git checkout #{my_branch} origin/#{my_branch} || git checkout #{my_branch})
%Q(cd #{path} && ) +
%Q((branch=`git symbolic-ref HEAD`; [ $branch == "refs/heads/#{my_branch}" ]) || ) +
%Q(git checkout -b #{my_branch} origin/#{my_branch} || git checkout #{my_branch} origin/#{my_branch} || git checkout #{my_branch})
end

def clone_repository(repo, path, my_branch)
Expand Down
7 changes: 6 additions & 1 deletion spec/whiskey_disk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,12 @@ def system(*args)

it 'does branch checkouts from the repository path' do
@whiskey_disk.checkout_main_repository
@whiskey_disk.buffer.join(' ').should.match(%r{cd /path/to/main/repo && git checkout})
@whiskey_disk.buffer.join(' ').should.match(%r{git checkout})
end

it 'should verify if branch is already checked out' do
@whiskey_disk.checkout_main_repository
@whiskey_disk.buffer.join(' ').should.match(%r{cd /path/to/main/repo && \(branch=\`git symbolic-ref HEAD\`; \[ \$branch == "refs/heads/master" \]\) \|\| git checkout})
end
end

Expand Down