Skip to content

Commit b6748c3

Browse files
committed
Merge pull request geelen#25 from kanet77/handle-renames
Handle local renamed but uncommitted files (git mv).
2 parents aeff8d3 + 787e972 commit b6748c3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/git-smart/git_repo.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ def status
9090
case status
9191
when /^[^ ]*M/; :modified
9292
when /^[^ ]*A/; :added
93+
when /^[^ ]*R/; :renamed
9394
when /^[^ ]*D/; :deleted
9495
when /^[^ ]*\?\?/; :untracked
9596
when /^[^ ]*UU/; :conflicted
96-
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}")
97+
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}")
9798
end
9899
}
99100
end

spec/smart-pull_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,21 @@ def remote_dir; WORKING_DIR + '/remote'; end
164164
local_dir.should have_git_status({:added => ['noob'], :modified => ['lib/codes.rb']})
165165
local_dir.should have_last_few_commits(['local changes', 'upstream changes', 'first'])
166166
end
167+
168+
it "should stash, rebase, pop if there are local renamed files" do
169+
%x[
170+
cd #{local_dir}
171+
git mv lib/codes.rb lib/codes2.rb
172+
]
173+
local_dir.should have_git_status({:renamed=>["lib/codes2.rb"]})
174+
out = run_command(local_dir, 'smart-pull')
175+
out.should report("Working directory dirty. Stashing...")
176+
out.should report("Executing: git stash")
177+
out.should report("Executing: git rebase -p origin/master")
178+
out.should report("Successfully rebased and updated refs/heads/master.")
179+
local_dir.should have_git_status({:deleted=>["lib/codes.rb"], :added=>["lib/codes2.rb"]})
180+
local_dir.should have_last_few_commits(['local changes', 'upstream changes', 'first'])
181+
end
167182
end
168183

169184
context 'with a submodule' do

0 commit comments

Comments
 (0)