Commit f8fa7a05 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'feature/migrate-force-push-check-to-gitaly' into 'master'

Migrate force push check to Gitaly

See merge request !13406
parents 3254ad4d daa0137b
...@@ -402,7 +402,7 @@ group :ed25519 do ...@@ -402,7 +402,7 @@ group :ed25519 do
end end
# Gitaly GRPC client # Gitaly GRPC client
gem 'gitaly', '~> 0.26.0' gem 'gitaly', '~> 0.27.0'
gem 'toml-rb', '~> 0.3.15', require: false gem 'toml-rb', '~> 0.3.15', require: false
......
...@@ -270,7 +270,7 @@ GEM ...@@ -270,7 +270,7 @@ GEM
po_to_json (>= 1.0.0) po_to_json (>= 1.0.0)
rails (>= 3.2.0) rails (>= 3.2.0)
gherkin-ruby (0.3.2) gherkin-ruby (0.3.2)
gitaly (0.26.0) gitaly (0.27.0)
google-protobuf (~> 3.1) google-protobuf (~> 3.1)
grpc (~> 1.0) grpc (~> 1.0)
github-linguist (4.7.6) github-linguist (4.7.6)
...@@ -984,7 +984,7 @@ DEPENDENCIES ...@@ -984,7 +984,7 @@ DEPENDENCIES
gettext (~> 3.2.2) gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.2.0) gettext_i18n_rails_js (~> 1.2.0)
gitaly (~> 0.26.0) gitaly (~> 0.27.0)
github-linguist (~> 4.7.0) github-linguist (~> 4.7.0)
gitlab-flowdock-git-hook (~> 1.0.1) gitlab-flowdock-git-hook (~> 1.0.1)
gitlab-markup (~> 1.5.1) gitlab-markup (~> 1.5.1)
......
...@@ -5,12 +5,19 @@ module Gitlab ...@@ -5,12 +5,19 @@ module Gitlab
return false if project.empty_repo? return false if project.empty_repo?
# Created or deleted branch # Created or deleted branch
if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev) return false if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev)
false
else GitalyClient.migrate(:force_push) do |is_enabled|
Gitlab::Git::RevList.new( if is_enabled
path_to_repo: project.repository.path_to_repo, !project
oldrev: oldrev, newrev: newrev).missed_ref.present? .repository
.gitaly_commit_client
.is_ancestor(oldrev, newrev)
else
Gitlab::Git::RevList.new(
path_to_repo: project.repository.path_to_repo,
oldrev: oldrev, newrev: newrev).missed_ref.present?
end
end end
end end
end end
......
...@@ -5,7 +5,9 @@ module Gitlab ...@@ -5,7 +5,9 @@ module Gitlab
def repository(repository_storage, relative_path) def repository(repository_storage, relative_path)
Gitaly::Repository.new( Gitaly::Repository.new(
storage_name: repository_storage, storage_name: repository_storage,
relative_path: relative_path relative_path: relative_path,
git_object_directory: Gitlab::Git::Env['GIT_OBJECT_DIRECTORY'].to_s,
git_alternate_object_directories: Array.wrap(Gitlab::Git::Env['GIT_ALTERNATE_OBJECT_DIRECTORIES'])
) )
end end
end end
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Checks::ForcePush do describe Gitlab::Checks::ForcePush do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
context "exit code checking" do context "exit code checking", skip_gitaly_mock: true do
it "does not raise a runtime error if the `popen` call to git returns a zero exit code" do it "does not raise a runtime error if the `popen` call to git returns a zero exit code" do
allow(Gitlab::Popen).to receive(:popen).and_return(['normal output', 0]) allow(Gitlab::Popen).to receive(:popen).and_return(['normal output', 0])
......
...@@ -217,7 +217,9 @@ describe Gitlab::Workhorse do ...@@ -217,7 +217,9 @@ describe Gitlab::Workhorse do
it 'includes a Repository param' do it 'includes a Repository param' do
repo_param = { Repository: { repo_param = { Repository: {
storage_name: 'default', storage_name: 'default',
relative_path: project.full_path + '.git' relative_path: project.full_path + '.git',
git_object_directory: '',
git_alternate_object_directories: []
} } } }
expect(subject).to include(repo_param) expect(subject).to include(repo_param)
......
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