2017-10-14 21:52:07 -04:00
|
|
|
module Gitlab
|
|
|
|
module Git
|
|
|
|
module RepositoryMirroring
|
2018-07-17 22:08:23 -04:00
|
|
|
def remote_branches(remote_name)
|
|
|
|
gitaly_migrate(:ref_find_all_remote_branches) do |is_enabled|
|
|
|
|
if is_enabled
|
|
|
|
gitaly_ref_client.remote_branches(remote_name)
|
|
|
|
else
|
2018-07-27 04:43:19 -04:00
|
|
|
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
|
|
|
|
rugged_remote_branches(remote_name)
|
|
|
|
end
|
2017-10-14 21:52:07 -04:00
|
|
|
end
|
2018-07-17 22:08:23 -04:00
|
|
|
end
|
2017-10-14 21:52:07 -04:00
|
|
|
end
|
|
|
|
|
2018-07-17 22:08:23 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def rugged_remote_branches(remote_name)
|
2017-10-14 21:52:07 -04:00
|
|
|
branches = []
|
|
|
|
|
|
|
|
rugged.references.each("refs/remotes/#{remote_name}/*").map do |ref|
|
2018-01-27 00:35:53 -05:00
|
|
|
name = ref.name.sub(%r{\Arefs/remotes/#{remote_name}/}, '')
|
2017-10-14 21:52:07 -04:00
|
|
|
|
|
|
|
begin
|
2018-07-18 07:12:57 -04:00
|
|
|
target_commit = Gitlab::Git::Commit.find(self, ref.target.oid)
|
2017-10-14 21:52:07 -04:00
|
|
|
branches << Gitlab::Git::Branch.new(self, name, ref.target, target_commit)
|
|
|
|
rescue Rugged::ReferenceError
|
|
|
|
# Omit invalid branch
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
branches
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|