summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-06-06 11:56:25 +0200
committerFrancisco Javier López <fjlopez@gitlab.com>2018-06-06 11:56:25 +0200
commit6176987c0db3fe13015f1f4e8151da19bff69c6e (patch)
tree48d2f8ef0f2b209ebb007c6ac29e67cdc94056b8
parent7b1fbc89951e16bf9181ae2da7467eaa392c825b (diff)
downloadgitlab-ce-fj-improve-lfs-pointers-retrieval.tar.gz
Some small improvements and specsfj-improve-lfs-pointers-retrieval
-rw-r--r--lib/gitlab/git/repository.rb20
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb18
2 files changed, 27 insertions, 11 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index d775c8f1f4d..d05d7179893 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1600,13 +1600,13 @@ module Gitlab
end
def all_lfs_pointers
- gitaly_migrate(:blob_get_all_lfs_pointers) do |is_enabled|
- if is_enabled
- gitaly_blob_client.get_all_lfs_pointers('HEAD')
- else
+ # gitaly_migrate(:blob_get_all_lfs_pointers) do |is_enabled|
+ # if is_enabled
+ # gitaly_blob_client.get_all_lfs_pointers('HEAD')
+ # else
git_all_lfs_pointers
- end
- end
+ # end
+ # end
end
private
@@ -2583,13 +2583,11 @@ module Gitlab
end
def git_lfs_track_patterns(file)
- git_rev_list_file_grep(file, "\s(.*/)*\\.gitattributes$").flat_map do |object_id, path|
+ git_rev_list_file_grep(file, "\s(.*/)*\\.gitattributes$").each_with_object([]) do |object_id, array|
blob = Gitlab::Git::Blob.raw(self, object_id)
- next unless blob
-
- git_lfs_track_pattern(blob.data)
- end.compact
+ array.concat(git_lfs_track_pattern(blob&.data))
+ end
end
# Selecting lfs patterns from the lfs attributes
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index 7a9621d9c78..4678b833b3c 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -2556,6 +2556,24 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
+ describe '#convert_lfs_pattern_to_regex' do
+ it 'converts recursive pattern' do
+ expect(repository.send(:convert_lfs_pattern_to_regex, '/directory/**/*.txt')).to eq 'directory/(.*/)*.*\\.txt'
+ end
+
+ it 'converts all files matcher into all character matcher' do
+ expect(repository.send(:convert_lfs_pattern_to_regex, '/*.txt')).to eq '.*\\.txt'
+ end
+ end
+
+ describe '#git_lfs_track_pattern' do
+ it 'returns the pattern of lfs filters' do
+ gitattributes = "*.txt filter=lfs diff=lfs merge=lfs -text\n*.png filter=other diff=other merge=other -text\n*.jpg filter=lfs diff=lfs merge=lfs -text\n"
+
+ expect(repository.send(:git_lfs_track_pattern, gitattributes)).to eq ['.*\\.jpg', '.*\\.txt']
+ end
+ end
+
def create_remote_branch(repository, remote_name, branch_name, source_branch_name)
source_branch = repository.branches.find { |branch| branch.name == source_branch_name }
rugged = repository_rugged