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

Handle local renamed but uncommitted files (git mv). #25

Open
wants to merge 1 commit into
base: master
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/git-smart/git_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions spec/smart-pull_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down