Skip to content

Commit

Permalink
Issue #11: rim/xxx branch is not forwarded when remote head is past x…
Browse files Browse the repository at this point in the history
…xx branch.
  • Loading branch information
Thomas Herrmann committed Nov 11, 2015
1 parent 8c49119 commit 06c50c9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/rim/sync_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ def sync(message = nil, rebase = nil, split = true)
remote_url = "file://" + @ws_root
tmpdir = clone_or_fetch_repository(remote_url, module_tmp_git_path(".ws"), "Cloning workspace git...")
RIM::git_session(tmpdir) do |tmp_session|
if tmp_session.current_branch() == rim_branch
tmp_session.execute("git reset --hard remotes/origin/#{rim_branch}")
tmp_session.execute("git clean -xdf")
else
tmp_session.execute("git reset --hard")
tmp_session.execute("git clean -xdf")
tmp_session.execute("git checkout #{rim_branch}")
end
tmp_session.execute("git reset --hard")
tmp_session.execute("git clean -xdf")
tmp_session.execute("git checkout -B #{rim_branch} remotes/origin/#{rim_branch}")
changed_modules = sync_modules(tmp_session, message)
if !split
tmp_session.execute("git reset --soft #{branch_sha1}")
Expand Down
42 changes: 42 additions & 0 deletions test/sync_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,48 @@ def test_case_change_in_filename_is_synced_correctly
end
end

def test_sync_on_different_branches
mod1_info = create_module_git("mod1")
create_ws_git("testbr")
cut = RIM::SyncHelper.new(@ws_dir, @logger, [mod1_info])
cut.sync
remote_path = path_from_module_info(mod1_info)
RIM::git_session(remote_path) do |s|
FileUtils.mv(File.join(remote_path, "readme.txt"), File.join(remote_path, "readme.tx_"))
s.execute("git add --all .")
s.execute("git commit -m \"Temporary change of filename within mod1\"")
FileUtils.mv(File.join(remote_path, "readme.tx_"), File.join(remote_path, "Readme.txt"))
s.execute("git add --all .")
s.execute("git commit -m \"Changed case in filename within mod1\"")
end
RIM::git_session(@ws_dir) do |s|
s.execute("git checkout -b branch2")
end
cut.sync
RIM::git_session(@ws_dir) do |s|
s.execute("git rebase rim/branch2")
out = s.execute("git show --name-only")
assert out.include?("Readme.txt")
end
RIM::git_session(remote_path) do |s|
`echo ' changed' >> #{File.join(remote_path, "Readme.txt")}`
s.execute("git commit . -m \"Changed module file\"")
end
cut.sync
RIM::git_session(@ws_dir) do |s|
s.execute("git rebase rim/branch2")
s.execute("git checkout testbr")
s.execute("git reset --hard branch2~1")
s.execute("git push origin branch2:branch2")
end
cut.sync
RIM::git_session(@ws_dir) do |s|
s.execute("git reset --hard rim/testbr")
out = s.execute("git show --name-only")
assert out.include?("Readme.txt")
end
end

private
def create_ws_git(branch = "master")
FileUtils.mkdir_p(@ws_remote_dir)
Expand Down

0 comments on commit 06c50c9

Please sign in to comment.