Skip to content

Commit

Permalink
Use pull instead of fetch_and_merge
Browse files Browse the repository at this point in the history
pull is a safer method as it does proper locking when multiple processes
are involved.
  • Loading branch information
Fryguy committed Aug 8, 2019
1 parent 0a0334f commit 414d473
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/models/git_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def update_repo
with_worktree do |worktree|
message = "Updating #{url} in #{directory_name}..."
_log.info(message)
worktree.send(:fetch_and_merge)
worktree.send(:pull)
_log.info("#{message}...Complete")
end
@updated_repo = true
Expand Down
18 changes: 9 additions & 9 deletions spec/models/git_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
repo.update_authentication(:default => {:userid => userid, :password => password})
expect(GitWorktree).to receive(:new).with(clone_args).and_return(gwt)
expect(GitWorktree).to receive(:new).with(args).and_return(gwt)
expect(gwt).to receive(:fetch_and_merge).with(no_args)
expect(gwt).to receive(:pull).with(no_args)

repo.refresh
expect(repo.default_authentication.userid).to eq(userid)
Expand All @@ -79,7 +79,7 @@
args[:certificate_check] = repo.method(:self_signed_cert_cb)
expect(GitWorktree).to receive(:new).with(clone_args).and_return(gwt)
expect(GitWorktree).to receive(:new).with(args).and_return(gwt)
expect(gwt).to receive(:fetch_and_merge).with(no_args)
expect(gwt).to receive(:pull).with(no_args)

repo.refresh
end
Expand All @@ -99,7 +99,7 @@

expect(repo).to receive(:clone_repo_if_missing).once.with(no_args).and_call_original
expect(GitWorktree).to receive(:new).with(anything).and_return(gwt)
expect(gwt).to receive(:fetch_and_merge).with(no_args)
expect(gwt).to receive(:pull).with(no_args)

repo.refresh
expect(repo.git_branches.collect(&:name)).to match_array(branch_list)
Expand All @@ -110,7 +110,7 @@
expect(GitWorktree).to receive(:new).twice.with(anything).and_return(gwt)
expect(gwt).to receive(:branches).with(anything).and_return(branch_list)
expect(gwt).to receive(:tags).with(no_args).and_return(tag_list)
expect(gwt).to receive(:fetch_and_merge).with(no_args)
expect(gwt).to receive(:pull).with(no_args)

allow(gwt).to receive(:branch_info) do |name|
branch_info_hash[name]
Expand All @@ -127,7 +127,7 @@
expect(GitWorktree).to receive(:new).twice.with(anything).and_return(gwt)
expect(gwt).to receive(:branches).with(anything).and_return(branch_list)
expect(gwt).to receive(:tags).with(no_args).and_return(tag_list)
expect(gwt).to receive(:fetch_and_merge).with(no_args)
expect(gwt).to receive(:pull).with(no_args)

allow(gwt).to receive(:branch_info) do |name|
branch_info_hash[name]
Expand All @@ -144,7 +144,7 @@
expect(GitWorktree).to receive(:new).twice.with(anything).and_return(gwt)
expect(gwt).to receive(:branches).with(anything).and_return(branch_list)
expect(gwt).to receive(:tags).with(no_args).and_return(tag_list)
expect(gwt).to receive(:fetch_and_merge).with(no_args)
expect(gwt).to receive(:pull).with(no_args)

allow(gwt).to receive(:branch_info) do |name|
branch_info_hash[name]
Expand All @@ -160,7 +160,7 @@
expect(GitWorktree).to receive(:new).twice.with(anything).and_return(gwt)
expect(gwt).to receive(:branches).with(anything).and_return(branch_list)
expect(gwt).to receive(:tags).with(no_args).and_return(tag_list)
expect(gwt).to receive(:fetch_and_merge).with(no_args)
expect(gwt).to receive(:pull).with(no_args)

allow(gwt).to receive(:branch_info) do |name|
branch_info_hash[name]
Expand All @@ -174,7 +174,7 @@

it "#refresh branches deleted" do
expect(GitWorktree).to receive(:new).twice.with(anything).and_return(gwt)
expect(gwt).to receive(:fetch_and_merge).twice.with(no_args)
expect(gwt).to receive(:pull).twice.with(no_args)
expect(gwt).to receive(:branches).twice.with(anything).and_return(branch_list)
expect(gwt).to receive(:tags).twice.with(no_args).and_return(tag_list)

Expand All @@ -194,7 +194,7 @@

it "#refresh tags deleted" do
expect(GitWorktree).to receive(:new).twice.with(anything).and_return(gwt)
expect(gwt).to receive(:fetch_and_merge).twice.with(no_args)
expect(gwt).to receive(:pull).twice.with(no_args)
expect(gwt).to receive(:branches).twice.with(anything).and_return(branch_list)
expect(gwt).to receive(:tags).twice.with(no_args).and_return(tag_list)

Expand Down

0 comments on commit 414d473

Please sign in to comment.