Skip to content

Commit

Permalink
Must reset the branch before checkout, in case it is dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeweaver committed Dec 29, 2015
1 parent ac96d68 commit cb847d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/git/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def push()
end

def checkout_branch(branch_name)
execute("reset --hard origin/#{branch_name}")
execute("checkout #{branch_name}")
execute("reset --hard origin/#{branch_name}")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/git/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def mock_execute(stdout_andstderr_str, status, execution_count=1)
end

it 'can checkout a branch' do
mock_execute('Success', 1, 2)
mock_execute('Success', 1, 3)
@git.checkout_branch('branch_name')
end

Expand Down

0 comments on commit cb847d7

Please sign in to comment.