diff options
| author | Robert Speicher <robert@gitlab.com> | 2017-08-11 20:43:25 +0000 |
|---|---|---|
| committer | Robert Speicher <robert@gitlab.com> | 2017-08-11 20:43:25 +0000 |
| commit | f8fa7a050ed7388345d5f8e8520461f447a00694 (patch) | |
| tree | cdbcc5ebeab6f22afe40cd15c8561e1aff1226d1 /lib | |
| parent | 3254ad4d5a4c8114d0580b64aafeb24bd8abf926 (diff) | |
| parent | daa0137b41eeec4008e8292971601fc8594b5329 (diff) | |
| download | gitlab-ce-f8fa7a050ed7388345d5f8e8520461f447a00694.tar.gz | |
Merge branch 'feature/migrate-force-push-check-to-gitaly' into 'master'
Migrate force push check to Gitaly
See merge request !13406
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab/checks/force_push.rb | 19 | ||||
| -rw-r--r-- | lib/gitlab/gitaly_client/util.rb | 4 |
2 files changed, 16 insertions, 7 deletions
diff --git a/lib/gitlab/checks/force_push.rb b/lib/gitlab/checks/force_push.rb index 1e73f89158d..714464fd5e7 100644 --- a/lib/gitlab/checks/force_push.rb +++ b/lib/gitlab/checks/force_push.rb @@ -5,12 +5,19 @@ module Gitlab return false if project.empty_repo? # Created or deleted branch - if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev) - false - else - Gitlab::Git::RevList.new( - path_to_repo: project.repository.path_to_repo, - oldrev: oldrev, newrev: newrev).missed_ref.present? + return false if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev) + + GitalyClient.migrate(:force_push) do |is_enabled| + if is_enabled + !project + .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 diff --git a/lib/gitlab/gitaly_client/util.rb b/lib/gitlab/gitaly_client/util.rb index f5a4c5493ef..8fc937496af 100644 --- a/lib/gitlab/gitaly_client/util.rb +++ b/lib/gitlab/gitaly_client/util.rb @@ -5,7 +5,9 @@ module Gitlab def repository(repository_storage, relative_path) Gitaly::Repository.new( 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 |
