Skip to content

Commit

Permalink
Merge pull request #22986 from agrare/move_git_worktree_pull_public
Browse files Browse the repository at this point in the history
Move `GitWorktree#pull` to a public method
  • Loading branch information
Fryguy authored Apr 10, 2024
2 parents 0f5c9c7 + 0d57a67 commit e94e922
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/git_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def update_repo
with_worktree do |worktree|
message = "Updating #{url} in #{directory_name}..."
_log.info(message)
worktree.send(:pull)
worktree.pull
_log.info("#{message}...Complete")
end
@updated_repo = true
Expand Down
8 changes: 4 additions & 4 deletions lib/git_worktree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ def checkout
end
end

def pull
lock { fetch_and_merge }
end

def with_remote_options
if @ssh_private_key
@ssh_private_key_file = Tempfile.new
Expand Down Expand Up @@ -328,10 +332,6 @@ def fetch
end
end

def pull
lock { fetch_and_merge }
end

def merge_and_push(commit)
rebase = false
push_lock do
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/git_worktree_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def open_existing_repo
expect(c_repo.file_list).to match_array(@ae_db.file_list)
@ae_db.mv_file_with_new_contents('A/File1.YamL', 'A/File11.YamL', "Hello")
@ae_db.save_changes("file renamed in master")
c_repo.send(:pull)
c_repo.pull
expect(c_repo.file_list).to match_array(@ae_db.file_list)
FileUtils.rm_rf(dirname) if Dir.exist?(dirname)
end
Expand All @@ -247,14 +247,14 @@ def open_existing_repo
end
end

describe "#pull (private)" do
describe "#pull" do
it "fetches the repo with proxy options" do
_dir, worktree = clone(@master_url)
expect(worktree.instance_variable_get(:@repo)).to receive(:fetch).with("origin", hash_including(:proxy_url => proxy_url))

worktree.instance_variable_set(:@proxy_url, proxy_url)

worktree.send(:pull)
worktree.pull
end
end
end
Expand Down

0 comments on commit e94e922

Please sign in to comment.