diff --git a/lib/git-smart/git_repo.rb b/lib/git-smart/git_repo.rb index 7df60c8..aa42208 100644 --- a/lib/git-smart/git_repo.rb +++ b/lib/git-smart/git_repo.rb @@ -90,10 +90,11 @@ def status case status when /^[^ ]*M/; :modified when /^[^ ]*A/; :added + when /^[^ ]*R/; :renamed when /^[^ ]*D/; :deleted when /^[^ ]*\?\?/; :untracked when /^[^ ]*UU/; :conflicted - else raise GitSmart::UnexpectedOutput.new("Expected the output of git status to only have lines starting with A, M, D, UU, or ??. Got: \n#{raw_status}") + else raise GitSmart::UnexpectedOutput.new("Expected the output of git status to only have lines starting with A, M, R, D, UU, or ??. Got: \n#{raw_status}") end } end diff --git a/spec/smart-pull_spec.rb b/spec/smart-pull_spec.rb index 63c5c30..a218bb6 100644 --- a/spec/smart-pull_spec.rb +++ b/spec/smart-pull_spec.rb @@ -164,6 +164,21 @@ def remote_dir; WORKING_DIR + '/remote'; end local_dir.should have_git_status({:added => ['noob'], :modified => ['lib/codes.rb']}) local_dir.should have_last_few_commits(['local changes', 'upstream changes', 'first']) end + + it "should stash, rebase, pop if there are local renamed files" do + %x[ + cd #{local_dir} + git mv lib/codes.rb lib/codes2.rb + ] + local_dir.should have_git_status({:renamed=>["lib/codes2.rb"]}) + out = run_command(local_dir, 'smart-pull') + out.should report("Working directory dirty. Stashing...") + out.should report("Executing: git stash") + out.should report("Executing: git rebase -p origin/master") + out.should report("Successfully rebased and updated refs/heads/master.") + local_dir.should have_git_status({:deleted=>["lib/codes.rb"], :added=>["lib/codes2.rb"]}) + local_dir.should have_last_few_commits(['local changes', 'upstream changes', 'first']) + end end context 'with a submodule' do