Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
commit9f46488805e86b1bc341ea1620b866016c2ce5ed (patch)
treef9748c7e287041e37d6da49e0a29c9511dc34768 /spec/lib/gitlab/git
parentdfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff)
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/lib/gitlab/git')
-rw-r--r--spec/lib/gitlab/git/attributes_parser_spec.rb8
-rw-r--r--spec/lib/gitlab/git/blob_spec.rb12
-rw-r--r--spec/lib/gitlab/git/commit_spec.rb20
-rw-r--r--spec/lib/gitlab/git/tag_spec.rb30
4 files changed, 70 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git/attributes_parser_spec.rb b/spec/lib/gitlab/git/attributes_parser_spec.rb
index 94b7a086e59..45db4acd3ac 100644
--- a/spec/lib/gitlab/git/attributes_parser_spec.rb
+++ b/spec/lib/gitlab/git/attributes_parser_spec.rb
@@ -75,6 +75,14 @@ describe Gitlab::Git::AttributesParser, :seed_helper do
expect(subject.attributes('test.foo')).to eq({})
end
end
+
+ context 'when attributes data has binary data' do
+ let(:data) { "\xFF\xFE*\u0000.\u0000c\u0000s".b }
+
+ it 'returns an empty Hash' do
+ expect(subject.attributes('test.foo')).to eq({})
+ end
+ end
end
describe '#patterns' do
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb
index 06f9767d58b..46d9b78c14b 100644
--- a/spec/lib/gitlab/git/blob_spec.rb
+++ b/spec/lib/gitlab/git/blob_spec.rb
@@ -652,4 +652,16 @@ describe Gitlab::Git::Blob, :seed_helper do
expect(described_class).to respond_to(:gitlab_blob_size)
end
end
+
+ describe '#lines' do
+ context 'when the encoding cannot be detected' do
+ it 'successfully splits the data' do
+ data = "test\nblob"
+ blob = Gitlab::Git::Blob.new(name: 'test', size: data.bytesize, data: data)
+ expect(blob).to receive(:ruby_encoding) { nil }
+
+ expect(blob.lines).to eq(data.split("\n"))
+ end
+ end
+ end
end
diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb
index c2fc228d34a..edd367673fb 100644
--- a/spec/lib/gitlab/git/commit_spec.rb
+++ b/spec/lib/gitlab/git/commit_spec.rb
@@ -161,6 +161,26 @@ describe Gitlab::Git::Commit, :seed_helper do
expect(described_class.find(repository, "+123_4532530XYZ")).to be_nil
end
+ it "returns nil for id started with dash" do
+ expect(described_class.find(repository, "-HEAD")).to be_nil
+ end
+
+ it "returns nil for id containing colon" do
+ expect(described_class.find(repository, "HEAD:")).to be_nil
+ end
+
+ it "returns nil for id containing space" do
+ expect(described_class.find(repository, "HE AD")).to be_nil
+ end
+
+ it "returns nil for id containing tab" do
+ expect(described_class.find(repository, "HE\tAD")).to be_nil
+ end
+
+ it "returns nil for id containing NULL" do
+ expect(described_class.find(repository, "HE\x00AD")).to be_nil
+ end
+
context 'with broken repo' do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_BROKEN_REPO_PATH, '', 'group/project') }
diff --git a/spec/lib/gitlab/git/tag_spec.rb b/spec/lib/gitlab/git/tag_spec.rb
index 87db3f588ad..6d3b239c38f 100644
--- a/spec/lib/gitlab/git/tag_spec.rb
+++ b/spec/lib/gitlab/git/tag_spec.rb
@@ -13,6 +13,13 @@ describe Gitlab::Git::Tag, :seed_helper do
it { expect(tag.target).to eq("f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8") }
it { expect(tag.dereferenced_target.sha).to eq("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") }
it { expect(tag.message).to eq("Release") }
+ it { expect(tag.has_signature?).to be_falsey }
+ it { expect(tag.signature_type).to eq(:NONE) }
+ it { expect(tag.signature).to be_nil }
+ it { expect(tag.tagger.name).to eq("Dmitriy Zaporozhets") }
+ it { expect(tag.tagger.email).to eq("dmitriy.zaporozhets@gmail.com") }
+ it { expect(tag.tagger.date).to eq(Google::Protobuf::Timestamp.new(seconds: 1393491299)) }
+ it { expect(tag.tagger.timezone).to eq("+0200") }
end
describe 'last tag' do
@@ -22,6 +29,29 @@ describe Gitlab::Git::Tag, :seed_helper do
it { expect(tag.target).to eq("2ac1f24e253e08135507d0830508febaaccf02ee") }
it { expect(tag.dereferenced_target.sha).to eq("fa1b1e6c004a68b7d8763b86455da9e6b23e36d6") }
it { expect(tag.message).to eq("Version 1.2.1") }
+ it { expect(tag.has_signature?).to be_falsey }
+ it { expect(tag.signature_type).to eq(:NONE) }
+ it { expect(tag.signature).to be_nil }
+ it { expect(tag.tagger.name).to eq("Douwe Maan") }
+ it { expect(tag.tagger.email).to eq("douwe@selenight.nl") }
+ it { expect(tag.tagger.date).to eq(Google::Protobuf::Timestamp.new(seconds: 1427789449)) }
+ it { expect(tag.tagger.timezone).to eq("+0200") }
+ end
+
+ describe 'signed tag' do
+ let(:project) { create(:project, :repository) }
+ let(:tag) { project.repository.find_tag('v1.1.1') }
+
+ it { expect(tag.target).to eq("8f03acbcd11c53d9c9468078f32a2622005a4841") }
+ it { expect(tag.dereferenced_target.sha).to eq("189a6c924013fc3fe40d6f1ec1dc20214183bc97") }
+ it { expect(tag.message).to eq("x509 signed tag" + "\n" + X509Helpers::User1.signed_tag_signature.chomp) }
+ it { expect(tag.has_signature?).to be_truthy }
+ it { expect(tag.signature_type).to eq(:X509) }
+ it { expect(tag.signature).not_to be_nil }
+ it { expect(tag.tagger.name).to eq("Roger Meier") }
+ it { expect(tag.tagger.email).to eq("r.meier@siemens.com") }
+ it { expect(tag.tagger.date).to eq(Google::Protobuf::Timestamp.new(seconds: 1574261780)) }
+ it { expect(tag.tagger.timezone).to eq("+0100") }
end
it { expect(repository.tags.size).to eq(SeedRepo::Repo::TAGS.size) }