Commit 7a355f68 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'gitaly-mandatory-20180703-jv-2' into 'master'

Remove more Gitaly feature flags

Closes gitaly#329, gitaly#320, gitaly#323, and gitaly#328

See merge request gitlab-org/gitlab-ce!20343
parents 48bbb363 201802f7
# Gitaly note: JV: 1 RPC, migration in progress.
# Gitlab::Git::CommitStats counts the additions, deletions, and total changes # Gitlab::Git::CommitStats counts the additions, deletions, and total changes
# in a commit. # in a commit.
module Gitlab module Gitlab
...@@ -16,12 +14,8 @@ module Gitlab ...@@ -16,12 +14,8 @@ module Gitlab
@deletions = 0 @deletions = 0
@total = 0 @total = 0
repo.gitaly_migrate(:commit_stats) do |is_enabled| repo.wrapped_gitaly_errors do
if is_enabled gitaly_stats(repo, commit)
gitaly_stats(repo, commit)
else
rugged_stats(commit)
end
end end
end end
...@@ -31,12 +25,6 @@ module Gitlab ...@@ -31,12 +25,6 @@ module Gitlab
@deletions = stats.deletions @deletions = stats.deletions
@total = @additions + @deletions @total = @additions + @deletions
end end
def rugged_stats(commit)
diff = commit.rugged_diff_from_parent
_files_changed, @additions, @deletions = diff.stat
@total = @additions + @deletions
end
end end
end end
end end
...@@ -251,7 +251,6 @@ module Gitlab ...@@ -251,7 +251,6 @@ module Gitlab
# Returns an Array of Tags # Returns an Array of Tags
# #
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/390
def tags def tags
wrapped_gitaly_errors do wrapped_gitaly_errors do
gitaly_ref_client.tags gitaly_ref_client.tags
...@@ -598,17 +597,9 @@ module Gitlab ...@@ -598,17 +597,9 @@ module Gitlab
# @repository.submodule_url_for('master', 'rack') # @repository.submodule_url_for('master', 'rack')
# # => git@localhost:rack.git # # => git@localhost:rack.git
# #
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/329
def submodule_url_for(ref, path) def submodule_url_for(ref, path)
Gitlab::GitalyClient.migrate(:submodule_url_for) do |is_enabled| wrapped_gitaly_errors do
if is_enabled gitaly_submodule_url_for(ref, path)
gitaly_submodule_url_for(ref, path)
else
if submodules(ref).any?
submodule = submodules(ref)[path]
submodule['url'] if submodule
end
end
end end
end end
...@@ -833,22 +824,14 @@ module Gitlab ...@@ -833,22 +824,14 @@ module Gitlab
# Ex. # Ex.
# repo.ls_files('master') # repo.ls_files('master')
# #
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/327
def ls_files(ref) def ls_files(ref)
gitaly_commit_client.ls_files(ref) gitaly_commit_client.ls_files(ref)
end end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/328
def copy_gitattributes(ref) def copy_gitattributes(ref)
Gitlab::GitalyClient.migrate(:apply_gitattributes) do |is_enabled| wrapped_gitaly_errors do
if is_enabled gitaly_repository_client.apply_gitattributes(ref)
gitaly_copy_gitattributes(ref)
else
rugged_copy_gitattributes(ref)
end
end end
rescue GRPC::InvalidArgument
raise InvalidRef
end end
def info_attributes def info_attributes
......
# Gitaly note: JV: needs 1 RPC, migration is in progress.
module Gitlab module Gitlab
module Git module Git
class Tree class Tree
...@@ -17,12 +15,8 @@ module Gitlab ...@@ -17,12 +15,8 @@ module Gitlab
def where(repository, sha, path = nil, recursive = false) def where(repository, sha, path = nil, recursive = false)
path = nil if path == '' || path == '/' path = nil if path == '' || path == '/'
Gitlab::GitalyClient.migrate(:tree_entries) do |is_enabled| repository.wrapped_gitaly_errors do
if is_enabled repository.gitaly_commit_client.tree_entries(repository, sha, path, recursive)
repository.gitaly_commit_client.tree_entries(repository, sha, path, recursive)
else
tree_entries_from_rugged(repository, sha, path, recursive)
end
end end
end end
......
...@@ -48,6 +48,8 @@ module Gitlab ...@@ -48,6 +48,8 @@ module Gitlab
def apply_gitattributes(revision) def apply_gitattributes(revision)
request = Gitaly::ApplyGitattributesRequest.new(repository: @gitaly_repo, revision: encode_binary(revision)) request = Gitaly::ApplyGitattributesRequest.new(repository: @gitaly_repo, revision: encode_binary(revision))
GitalyClient.call(@storage, :repository_service, :apply_gitattributes, request) GitalyClient.call(@storage, :repository_service, :apply_gitattributes, request)
rescue GRPC::InvalidArgument => ex
raise Gitlab::Git::Repository::InvalidRef, ex
end end
def info_attributes def info_attributes
......
...@@ -1402,94 +1402,84 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -1402,94 +1402,84 @@ describe Gitlab::Git::Repository, seed_helper: true do
end end
describe "#copy_gitattributes" do describe "#copy_gitattributes" do
shared_examples 'applying git attributes' do let(:attributes_path) { File.join(SEED_STORAGE_PATH, TEST_REPO_PATH, 'info/attributes') }
let(:attributes_path) { File.join(SEED_STORAGE_PATH, TEST_REPO_PATH, 'info/attributes') }
after do after do
FileUtils.rm_rf(attributes_path) if Dir.exist?(attributes_path) FileUtils.rm_rf(attributes_path) if Dir.exist?(attributes_path)
end end
it "raises an error with invalid ref" do
expect { repository.copy_gitattributes("invalid") }.to raise_error(Gitlab::Git::Repository::InvalidRef)
end
context 'when forcing encoding issues' do
let(:branch_name) { "ʕ•ᴥ•ʔ" }
before do it "raises an error with invalid ref" do
repository.create_branch(branch_name, "master") expect { repository.copy_gitattributes("invalid") }.to raise_error(Gitlab::Git::Repository::InvalidRef)
end end
after do context 'when forcing encoding issues' do
repository.rm_branch(branch_name, user: build(:admin)) let(:branch_name) { "ʕ•ᴥ•ʔ" }
end
it "doesn't raise with a valid unicode ref" do before do
expect { repository.copy_gitattributes(branch_name) }.not_to raise_error repository.create_branch(branch_name, "master")
end
repository after do
end repository.rm_branch(branch_name, user: build(:admin))
end end
context "with no .gitattrbutes" do it "doesn't raise with a valid unicode ref" do
before do expect { repository.copy_gitattributes(branch_name) }.not_to raise_error
repository.copy_gitattributes("master")
end
it "does not have an info/attributes" do repository
expect(File.exist?(attributes_path)).to be_falsey
end
end end
end
context "with .gitattrbutes" do context "with no .gitattrbutes" do
before do before do
repository.copy_gitattributes("gitattributes") repository.copy_gitattributes("master")
end end
it "has an info/attributes" do it "does not have an info/attributes" do
expect(File.exist?(attributes_path)).to be_truthy expect(File.exist?(attributes_path)).to be_falsey
end end
end
it "has the same content in info/attributes as .gitattributes" do context "with .gitattrbutes" do
contents = File.open(attributes_path, "rb") { |f| f.read } before do
expect(contents).to eq("*.md binary\n") repository.copy_gitattributes("gitattributes")
end
end end
context "with updated .gitattrbutes" do it "has an info/attributes" do
before do expect(File.exist?(attributes_path)).to be_truthy
repository.copy_gitattributes("gitattributes") end
repository.copy_gitattributes("gitattributes-updated")
end
it "has an info/attributes" do it "has the same content in info/attributes as .gitattributes" do
expect(File.exist?(attributes_path)).to be_truthy contents = File.open(attributes_path, "rb") { |f| f.read }
end expect(contents).to eq("*.md binary\n")
end
end
it "has the updated content in info/attributes" do context "with updated .gitattrbutes" do
contents = File.read(attributes_path) before do
expect(contents).to eq("*.txt binary\n") repository.copy_gitattributes("gitattributes")
end repository.copy_gitattributes("gitattributes-updated")
end end
context "with no .gitattrbutes in HEAD but with previous info/attributes" do it "has an info/attributes" do
before do expect(File.exist?(attributes_path)).to be_truthy
repository.copy_gitattributes("gitattributes") end
repository.copy_gitattributes("master")
end
it "does not have an info/attributes" do it "has the updated content in info/attributes" do
expect(File.exist?(attributes_path)).to be_falsey contents = File.read(attributes_path)
end expect(contents).to eq("*.txt binary\n")
end end
end end
context 'when gitaly is enabled' do context "with no .gitattrbutes in HEAD but with previous info/attributes" do
it_behaves_like 'applying git attributes' before do
end repository.copy_gitattributes("gitattributes")
repository.copy_gitattributes("master")
end
context 'when gitaly is disabled', :disable_gitaly do it "does not have an info/attributes" do
it_behaves_like 'applying git attributes' expect(File.exist?(attributes_path)).to be_falsey
end
end end
end end
......
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