Commit 400557f0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'gitaly-fetch-remote' into 'master'

Add `Gitlab::Git::Repository#fetch` command

Closes gitaly#586

See merge request gitlab-org/gitlab-ce!14772
parents ca06ff27 17319343
...@@ -1086,6 +1086,12 @@ module Gitlab ...@@ -1086,6 +1086,12 @@ module Gitlab
@has_visible_content = has_local_branches? @has_visible_content = has_local_branches?
end end
def fetch(remote = 'origin')
args = %W(#{Gitlab.config.git.bin_path} fetch #{remote})
popen(args, @path).last.zero?
end
def gitaly_repository def gitaly_repository
Gitlab::GitalyClient::Util.repository(@storage, @relative_path, @gl_repository) Gitlab::GitalyClient::Util.repository(@storage, @relative_path, @gl_repository)
end end
......
...@@ -1510,6 +1510,21 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -1510,6 +1510,21 @@ describe Gitlab::Git::Repository, seed_helper: true do
end end
end end
describe '#fetch' do
let(:git_path) { Gitlab.config.git.bin_path }
let(:remote_name) { 'my_remote' }
subject { repository.fetch(remote_name) }
it 'fetches the remote and returns true if the command was successful' do
expect(repository).to receive(:popen)
.with(%W(#{git_path} fetch #{remote_name}), repository.path)
.and_return(['', 0])
expect(subject).to be(true)
end
end
def create_remote_branch(repository, remote_name, branch_name, source_branch_name) def create_remote_branch(repository, remote_name, branch_name, source_branch_name)
source_branch = repository.branches.find { |branch| branch.name == source_branch_name } source_branch = repository.branches.find { |branch| branch.name == source_branch_name }
rugged = repository.rugged rugged = repository.rugged
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment