diff options
author | Alejandro Rodríguez <alejorro70@gmail.com> | 2018-10-13 19:02:37 +0300 |
---|---|---|
committer | Alejandro Rodríguez <alejorro70@gmail.com> | 2018-10-15 06:20:40 +0300 |
commit | 5b85a26399aabce57d655f75c10e810c52b86911 (patch) | |
tree | 82e9d12e2222e0e971191a0cea18536c64bc3590 | |
parent | 85a8edf0fe840a21056befaf0d221a5a7dd9de5e (diff) |
Add tag spec examples and remove unused code
-rw-r--r-- | ruby/lib/gitlab/git/tag.rb | 41 | ||||
-rw-r--r-- | ruby/spec/lib/gitlab/git/blob_spec.rb | 2 | ||||
-rw-r--r-- | ruby/spec/lib/gitlab/git/branch_spec.rb | 2 | ||||
-rw-r--r-- | ruby/spec/lib/gitlab/git/commit_spec.rb | 2 | ||||
-rw-r--r-- | ruby/spec/lib/gitlab/git/remote_repository_spec.rb | 2 | ||||
-rw-r--r-- | ruby/spec/lib/gitlab/git/repository_spec.rb | 22 |
6 files changed, 27 insertions, 44 deletions
diff --git a/ruby/lib/gitlab/git/tag.rb b/ruby/lib/gitlab/git/tag.rb index 706b12b5f..1cb150f84 100644 --- a/ruby/lib/gitlab/git/tag.rb +++ b/ruby/lib/gitlab/git/tag.rb @@ -7,33 +7,10 @@ module Gitlab attr_reader :object_sha, :repository - MAX_TAG_MESSAGE_DISPLAY_SIZE = 10.megabytes SERIALIZE_KEYS = %i[name target target_commit message].freeze attr_accessor *SERIALIZE_KEYS # rubocop:disable Lint/AmbiguousOperator - class << self - def get_message(repository, tag_id) - BatchLoader.for({ repository: repository, tag_id: tag_id }).batch do |items, loader| - items_by_repo = items.group_by { |i| i[:repository] } - - items_by_repo.each do |repo, items| - tag_ids = items.map { |i| i[:tag_id] } - - messages = get_messages(repository, tag_ids) - - messages.each do |id, message| - loader.call({ repository: repository, tag_id: id }, message) - end - end - end - end - - def get_messages(repository, tag_ids) - repository.gitaly_ref_client.get_tag_messages(tag_ids) - end - end - def initialize(repository, raw_tag) @repository = repository @raw_tag = raw_tag @@ -59,7 +36,7 @@ module Gitlab def init_from_gitaly @name = encode!(@raw_tag.name.dup) @target = @raw_tag.id - @message = message_from_gitaly_tag + @message = @raw_tag.message.dup if @raw_tag.target_commit.present? @target_commit = Gitlab::Git::Commit.decorate(repository, @raw_tag.target_commit) @@ -69,22 +46,6 @@ module Gitlab def message encode! @message end - - private - - def message_from_gitaly_tag - return @raw_tag.message.dup if full_message_fetched_from_gitaly? - - if @raw_tag.message_size > MAX_TAG_MESSAGE_DISPLAY_SIZE - '--tag message is too big' - else - self.class.get_message(@repository, target) - end - end - - def full_message_fetched_from_gitaly? - @raw_tag.message.bytesize == @raw_tag.message_size - end end end end diff --git a/ruby/spec/lib/gitlab/git/blob_spec.rb b/ruby/spec/lib/gitlab/git/blob_spec.rb index 41bb41a18..165cdf3ae 100644 --- a/ruby/spec/lib/gitlab/git/blob_spec.rb +++ b/ruby/spec/lib/gitlab/git/blob_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe Gitlab::Git::Blob, :seed_helper do +describe Gitlab::Git::Blob do include TestRepo let(:repository) { gitlab_git_from_gitaly(git_test_repo_read_only) } diff --git a/ruby/spec/lib/gitlab/git/branch_spec.rb b/ruby/spec/lib/gitlab/git/branch_spec.rb index 344534238..c32f72f22 100644 --- a/ruby/spec/lib/gitlab/git/branch_spec.rb +++ b/ruby/spec/lib/gitlab/git/branch_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe Gitlab::Git::Branch, :seed_helper do +describe Gitlab::Git::Branch do include TestRepo let(:repository) { gitlab_git_from_gitaly(git_test_repo_read_only) } diff --git a/ruby/spec/lib/gitlab/git/commit_spec.rb b/ruby/spec/lib/gitlab/git/commit_spec.rb index 97b02c208..ce3c19f8a 100644 --- a/ruby/spec/lib/gitlab/git/commit_spec.rb +++ b/ruby/spec/lib/gitlab/git/commit_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe Gitlab::Git::Commit, :seed_helper do +describe Gitlab::Git::Commit do include TestRepo let(:repository) { gitlab_git_from_gitaly(git_test_repo_read_only) } diff --git a/ruby/spec/lib/gitlab/git/remote_repository_spec.rb b/ruby/spec/lib/gitlab/git/remote_repository_spec.rb index 2788f482b..df9468594 100644 --- a/ruby/spec/lib/gitlab/git/remote_repository_spec.rb +++ b/ruby/spec/lib/gitlab/git/remote_repository_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Git::RemoteRepository, :seed_helper do +describe Gitlab::Git::RemoteRepository do include TestRepo let(:repository) { gitlab_git_from_gitaly(git_test_repo_read_only) } diff --git a/ruby/spec/lib/gitlab/git/repository_spec.rb b/ruby/spec/lib/gitlab/git/repository_spec.rb index 8401a8711..4a4caa6ad 100644 --- a/ruby/spec/lib/gitlab/git/repository_spec.rb +++ b/ruby/spec/lib/gitlab/git/repository_spec.rb @@ -98,6 +98,28 @@ describe Gitlab::Git::Repository do it { is_expected.not_to include("branch-from-space") } end + describe '#tags' do + describe 'first tag' do + let(:tag) { repository.tags.first } + + it { expect(tag.name).to eq("v1.0.0") } + it { expect(tag.target).to eq("f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8") } + it { expect(tag.dereferenced_target.sha).to eq("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") } + it { expect(tag.message).to eq("Release") } + end + + describe 'last tag' do + let(:tag) { repository.tags.last } + + it { expect(tag.name).to eq("v1.2.1") } + 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") } + end + + it { expect(repository.tags.size).to eq(SeedRepo::Repo::TAGS.size) } + end + describe '#tag_names' do subject { repository.tag_names } |