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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Cai <jcai@gitlab.com>2019-04-04 23:48:40 +0300
committerJohn Cai <jcai@gitlab.com>2019-04-04 23:48:40 +0300
commit6cc4eb0f49fbd57d75f6e31045d5a96fe1d0286b (patch)
tree44e071b71861df658ba87b71d38304d16c587932
parentd3ce461428a58b44430a24b85a15af059be4bf80 (diff)
parented7a231ef96303b20b65fd3cdd49205dc03d6e20 (diff)
Merge branch 'zj-remove-dead-gitlab-git-code' into 'master'
Remove dead gitlab git code See merge request gitlab-org/gitaly!1178
-rw-r--r--ruby/lib/gitlab/git.rb9
-rw-r--r--ruby/lib/gitlab/git/branch.rb8
-rw-r--r--ruby/lib/gitlab/git/commit.rb30
-rw-r--r--ruby/lib/gitlab/git/gitlab_projects.rb4
-rw-r--r--ruby/lib/gitlab/git/raw_diff_change.rb66
-rw-r--r--ruby/lib/gitlab/git/repository.rb79
-rw-r--r--ruby/lib/gitlab/version_info.rb54
-rw-r--r--ruby/spec/lib/gitlab/git/branch_spec.rb44
-rw-r--r--ruby/spec/lib/gitlab/git/commit_spec.rb4
-rw-r--r--ruby/spec/lib/gitlab/git/raw_diff_change_spec.rb68
-rw-r--r--ruby/spec/lib/gitlab/git/repository_spec.rb72
-rw-r--r--ruby/spec/lib/gitlab/version_info_spec.rb66
12 files changed, 1 insertions, 503 deletions
diff --git a/ruby/lib/gitlab/git.rb b/ruby/lib/gitlab/git.rb
index 110ac0547..09b6e8b37 100644
--- a/ruby/lib/gitlab/git.rb
+++ b/ruby/lib/gitlab/git.rb
@@ -16,7 +16,6 @@ require_relative 'git_logger.rb'
require_relative 'rails_logger.rb'
require_relative 'gollum.rb'
require_relative 'config.rb'
-require_relative 'version_info'
dir = __dir__
@@ -124,14 +123,6 @@ module Gitlab
sha1[0, length] == sha2[0, length]
end
end
-
- module Version
- extend Gitlab::Git::Popen
-
- def self.git_version
- Gitlab::VersionInfo.parse(popen(%W(#{Gitlab.config.git.bin_path} --version), nil).first)
- end
- end
end
end
diff --git a/ruby/lib/gitlab/git/branch.rb b/ruby/lib/gitlab/git/branch.rb
index ab11401c8..9618b5fef 100644
--- a/ruby/lib/gitlab/git/branch.rb
+++ b/ruby/lib/gitlab/git/branch.rb
@@ -3,14 +3,6 @@ require_relative 'ref'
module Gitlab
module Git
class Branch < Ref
- def self.find(repo, branch_name)
- if branch_name.is_a?(Gitlab::Git::Branch)
- branch_name
- else
- repo.find_branch(branch_name)
- end
- end
-
def initialize(repository, name, target, target_commit)
super(repository, name, target, target_commit)
end
diff --git a/ruby/lib/gitlab/git/commit.rb b/ruby/lib/gitlab/git/commit.rb
index 9a420c04b..0e8ea0fd7 100644
--- a/ruby/lib/gitlab/git/commit.rb
+++ b/ruby/lib/gitlab/git/commit.rb
@@ -103,19 +103,6 @@ module Gitlab
@safe_message ||= message
end
- def created_at
- committed_date
- end
-
- # Was this commit committed by a different person than the original author?
- def different_committer?
- author_name != committer_name || author_email != committer_email
- end
-
- def parent_id
- parent_ids.first
- end
-
# Not to be called directly, but right now its used for tests and in old
# migrations
def rugged_diff_from_parent(options = {})
@@ -183,23 +170,6 @@ module Gitlab
parent_ids.size > 1
end
- def tree_entry(path)
- return unless path.present?
-
- # We're only interested in metadata, so limit actual data to 1 byte
- # since Gitaly doesn't support "send no data" option.
- entry = @repository.gitaly_commit_client.tree_entry(id, path, 1)
- return unless entry
-
- # To be compatible with the rugged format
- entry = entry.to_h
- entry.delete(:data)
- entry[:name] = File.basename(path)
- entry[:type] = entry[:type].downcase
-
- entry
- end
-
def to_gitaly_commit
return raw_commit if raw_commit.is_a?(Gitaly::GitCommit)
diff --git a/ruby/lib/gitlab/git/gitlab_projects.rb b/ruby/lib/gitlab/git/gitlab_projects.rb
index 011c01f06..3c7453961 100644
--- a/ruby/lib/gitlab/git/gitlab_projects.rb
+++ b/ruby/lib/gitlab/git/gitlab_projects.rb
@@ -37,10 +37,6 @@ module Gitlab
@output = StringIO.new
end
- def shard_name
- raise "don't use shard_name in gitaly-ruby"
- end
-
def shard_path
@shard_path
end
diff --git a/ruby/lib/gitlab/git/raw_diff_change.rb b/ruby/lib/gitlab/git/raw_diff_change.rb
deleted file mode 100644
index e27b277a3..000000000
--- a/ruby/lib/gitlab/git/raw_diff_change.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# TODO: remove after 11.8 because of https://gitlab.com/gitlab-org/gitaly/merge_requests/1026
-
-module Gitlab
- module Git
- class RawDiffChange
- attr_reader :blob_id, :blob_size, :old_path, :new_path, :operation, :old_mode, :new_mode
-
- def initialize(raw_change, old_mode, new_mode)
- parse(raw_change)
-
- @old_mode = old_mode
- @new_mode = new_mode
- end
-
- private
-
- # Input data has the following format:
- #
- # When a file has been modified:
- # 7e3e39ebb9b2bf433b4ad17313770fbe4051649c 669 M\tfiles/ruby/popen.rb
- #
- # When a file has been renamed:
- # 85bc2f9753afd5f4fc5d7c75f74f8d526f26b4f3 107 R060\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee
- def parse(raw_change)
- @blob_id, @blob_size, @raw_operation, raw_paths = raw_change.split(' ', 4)
- @blob_size = @blob_size.to_i
- @operation = extract_operation
- @old_path, @new_path = extract_paths(raw_paths)
- end
-
- def extract_paths(file_path)
- case operation
- when :copied, :renamed
- file_path.split(/\t/)
- when :deleted
- [file_path, nil]
- when :added
- [nil, file_path]
- else
- [file_path, file_path]
- end
- end
-
- def extract_operation
- return :unknown unless @raw_operation
-
- case @raw_operation[0]
- when 'A'
- :added
- when 'C'
- :copied
- when 'D'
- :deleted
- when 'M'
- :modified
- when 'R'
- :renamed
- when 'T'
- :type_changed
- else
- :unknown
- end
- end
- end
- end
-end
diff --git a/ruby/lib/gitlab/git/repository.rb b/ruby/lib/gitlab/git/repository.rb
index 1a0b7d044..030bece0b 100644
--- a/ruby/lib/gitlab/git/repository.rb
+++ b/ruby/lib/gitlab/git/repository.rb
@@ -260,55 +260,6 @@ module Gitlab
false
end
- # TODO: remove after 11.8 because of https://gitlab.com/gitlab-org/gitaly/merge_requests/1026
- def raw_changes_between(old_rev, new_rev)
- @raw_changes_between ||= {}
-
- @raw_changes_between[[old_rev, new_rev]] ||=
- begin
- return [] if new_rev.blank? || new_rev == Gitlab::Git::BLANK_SHA
-
- result = []
-
- Open3.popen3(*git_diff_cmd(old_rev, new_rev)) do |_stdin, stdout, _stderr, wait_thr|
- cat_stdin, cat_stdout, cat_stderr, cat_wait_thr = Open3.popen3(*git_cat_file_cmd)
-
- stdout.each_line do |line|
- old_mode, new_mode, blob_id, rest = parse_raw_diff_line(line)
- cat_stdin.puts("#{blob_id} #{rest}")
- result << ::Gitlab::Git::RawDiffChange.new(cat_stdout.gets.chomp, old_mode, new_mode)
- end
-
- cat_stdin.close
- cat_stdout.close
- cat_stderr.close
-
- raise ::Gitlab::Git::Repository::GitError, "Unabled to obtain changes between #{old_rev} and #{new_rev}" unless [cat_wait_thr, wait_thr].all? { |waiter| waiter.value&.success? }
- end
-
- result
- end
- rescue ArgumentError => e
- raise Gitlab::Git::Repository::GitError, e.to_s
- end
-
- # TODO: remove after 11.8 because of https://gitlab.com/gitlab-org/gitaly/merge_requests/1026
- def parse_raw_diff_line(line)
- old_mode, new_mode, old_blob_id, new_blob_id, rest = line.split(/\s/, 5)
-
- # If the last element got a value we should be good
- raise ArgumentError, "Invalid diff line: #{line}" unless rest
-
- old_mode.gsub!(/\A:/, '')
- old_blob_id.gsub!(/[^\h]/, '')
- new_blob_id.gsub!(/[^\h]/, '')
-
- # We can't pass '0000000...' to `git cat-file` given it will not return info about the deleted file
- blob_id = new_blob_id.match?(/\A0+\z/) ? old_blob_id : new_blob_id
-
- [old_mode, new_mode, blob_id, rest]
- end
-
def add_tag(tag_name, user:, target:, message: nil)
target_object = Ref.dereference_object(lookup(target))
raise InvalidRef, "target not found: #{target}" unless target_object
@@ -897,32 +848,6 @@ module Gitlab
sort_branches(branches, sort_by)
end
- def build_git_cmd(*args)
- object_directories = alternate_object_directories.join(File::PATH_SEPARATOR)
-
- env = { 'PWD' => path }
- env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = object_directories if object_directories.present?
-
- [
- env,
- ::Gitlab.config.git.bin_path,
- *args,
- { chdir: path }
- ]
- end
-
- # TODO: remove after 11.8 because of https://gitlab.com/gitlab-org/gitaly/merge_requests/1026
- def git_diff_cmd(old_rev, new_rev)
- old_rev = old_rev == ::Gitlab::Git::BLANK_SHA ? ::Gitlab::Git::EMPTY_TREE_ID : old_rev
-
- build_git_cmd('diff', old_rev, new_rev, '--raw')
- end
-
- def git_cat_file_cmd
- format = '%(objectname) %(objectsize) %(rest)'
- build_git_cmd('cat-file', "--batch-check=#{format}")
- end
-
def git_delete_refs(*ref_names)
instructions = ref_names.map do |ref|
"delete #{ref}\x00\x00"
@@ -1045,10 +970,6 @@ module Gitlab
end
end
- def sha_from_ref(ref)
- rev_parse_target(ref).oid
- end
-
def gitlab_projects_error
raise CommandError, @gitlab_projects.output
end
diff --git a/ruby/lib/gitlab/version_info.rb b/ruby/lib/gitlab/version_info.rb
deleted file mode 100644
index b5f4bec54..000000000
--- a/ruby/lib/gitlab/version_info.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-module Gitlab
- class VersionInfo
- include Comparable
-
- attr_reader :major, :minor, :patch
-
- def self.parse(str)
- if str && m = str.match(/(\d+)\.(\d+)\.(\d+)/)
- VersionInfo.new(m[1].to_i, m[2].to_i, m[3].to_i)
- else
- VersionInfo.new
- end
- end
-
- def initialize(major = 0, minor = 0, patch = 0)
- @major = major
- @minor = minor
- @patch = patch
- end
-
- def <=>(other)
- return unless other.is_a? VersionInfo
- return unless valid? && other.valid?
-
- if other.major < @major
- 1
- elsif @major < other.major
- -1
- elsif other.minor < @minor
- 1
- elsif @minor < other.minor
- -1
- elsif other.patch < @patch
- 1
- elsif @patch < other.patch
- -1
- else
- 0
- end
- end
-
- def to_s
- if valid?
- format("%d.%d.%d", @major, @minor, @patch)
- else
- "Unknown"
- end
- end
-
- def valid?
- @major >= 0 && @minor >= 0 && @patch >= 0 && @major + @minor + @patch > 0
- end
- end
-end
diff --git a/ruby/spec/lib/gitlab/git/branch_spec.rb b/ruby/spec/lib/gitlab/git/branch_spec.rb
index 8d99d2eaa..3381fc230 100644
--- a/ruby/spec/lib/gitlab/git/branch_spec.rb
+++ b/ruby/spec/lib/gitlab/git/branch_spec.rb
@@ -4,44 +4,10 @@ describe Gitlab::Git::Branch do
include TestRepo
let(:repository) { gitlab_git_from_gitaly(git_test_repo_read_only) }
- let(:rugged) do
- Rugged::Repository.new(GIT_TEST_REPO_PATH)
- end
subject { repository.branches }
- it { is_expected.to be_kind_of Array }
-
- describe '.find' do
- subject { described_class.find(repository, branch) }
-
- before do
- allow(repository).to receive(:find_branch).with(branch).and_call_original
- end
-
- context 'when finding branch via branch name' do
- let(:branch) { 'master' }
-
- it 'returns a branch object' do
- expect(subject).to be_a(described_class)
- expect(subject.name).to eq(branch)
-
- expect(repository).to have_received(:find_branch).with(branch)
- end
- end
-
- context 'when the argument is already a branch' do
- let(:commit) { repository.commit('master') }
- let(:branch) { described_class.new(repository, 'master', commit.sha, commit) }
-
- it 'returns a branch object' do
- expect(subject).to be_a(described_class)
- expect(subject).to eq(branch)
-
- expect(repository).not_to have_received(:find_branch)
- end
- end
- end
+ it { is_expected.to be_an(Array) }
describe '#size' do
subject { super().size }
@@ -49,13 +15,5 @@ describe Gitlab::Git::Branch do
it { is_expected.to eq(SeedRepo::Repo::BRANCHES.size) }
end
- describe 'master branch' do
- let(:branch) do
- repository.branches.find { |branch| branch.name == 'master' }
- end
-
- it { expect(branch.dereferenced_target.sha).to eq(SeedRepo::LastCommit::ID) }
- end
-
it { expect(repository.branches.size).to eq(SeedRepo::Repo::BRANCHES.size) }
end
diff --git a/ruby/spec/lib/gitlab/git/commit_spec.rb b/ruby/spec/lib/gitlab/git/commit_spec.rb
index 217e226b9..0a69efb8e 100644
--- a/ruby/spec/lib/gitlab/git/commit_spec.rb
+++ b/ruby/spec/lib/gitlab/git/commit_spec.rb
@@ -46,15 +46,12 @@ describe Gitlab::Git::Commit do
it { expect(commit.id).to eq(rugged_commit.oid) }
it { expect(commit.sha).to eq(rugged_commit.oid) }
it { expect(commit.safe_message).to eq(rugged_commit.message) }
- it { expect(commit.created_at).to eq(rugged_commit.author[:time]) }
it { expect(commit.date).to eq(rugged_commit.committer[:time]) }
it { expect(commit.author_email).to eq(author[:email]) }
it { expect(commit.author_name).to eq(author[:name]) }
it { expect(commit.committer_name).to eq(committer[:name]) }
it { expect(commit.committer_email).to eq(committer[:email]) }
- it { expect(commit.different_committer?).to be_truthy }
it { expect(commit.parents).to eq(gitlab_parents) }
- it { expect(commit.parent_id).to eq(parents.first.oid) }
it { expect(commit.no_commit_message).to eq("--no commit message") }
end
@@ -72,7 +69,6 @@ describe Gitlab::Git::Commit do
it { expect(commit.id).to eq(id) }
it { expect(commit.sha).to eq(id) }
it { expect(commit.safe_message).to eq(body) }
- it { expect(commit.created_at).to eq(Time.at(committer.date.seconds)) }
it { expect(commit.author_email).to eq(author.email) }
it { expect(commit.author_name).to eq(author.name) }
it { expect(commit.committer_name).to eq(committer.name) }
diff --git a/ruby/spec/lib/gitlab/git/raw_diff_change_spec.rb b/ruby/spec/lib/gitlab/git/raw_diff_change_spec.rb
deleted file mode 100644
index 071b9a21c..000000000
--- a/ruby/spec/lib/gitlab/git/raw_diff_change_spec.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-require 'spec_helper'
-
-describe Gitlab::Git::RawDiffChange do
- let(:raw_change) {}
- let(:old_mode) { 0o100644 }
- let(:new_mode) { 0o100644 }
- let(:change) { described_class.new(raw_change, old_mode, new_mode) }
-
- context 'bad input' do
- let(:raw_change) { 'foo' }
-
- it 'does not set most of the attrs' do
- expect(change.blob_id).to eq('foo')
- expect(change.operation).to eq(:unknown)
- expect(change.old_path).to be_blank
- expect(change.new_path).to be_blank
- expect(change.blob_size).to eq(0)
- end
- end
-
- context 'adding a file' do
- let(:raw_change) { '93e123ac8a3e6a0b600953d7598af629dec7b735 59 A bar/branch-test.txt' }
-
- it 'initialize the proper attrs' do
- expect(change.operation).to eq(:added)
- expect(change.old_path).to be_blank
- expect(change.new_path).to eq('bar/branch-test.txt')
- expect(change.blob_id).to be_present
- expect(change.blob_size).to be_present
- end
- end
-
- context 'renaming a file' do
- let(:raw_change) { "85bc2f9753afd5f4fc5d7c75f74f8d526f26b4f3 107 R060\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee" }
-
- it 'initialize the proper attrs' do
- expect(change.operation).to eq(:renamed)
- expect(change.old_path).to eq('files/js/commit.js.coffee')
- expect(change.new_path).to eq('files/js/commit.coffee')
- expect(change.blob_id).to be_present
- expect(change.blob_size).to be_present
- end
- end
-
- context 'modifying a file' do
- let(:raw_change) { 'c60514b6d3d6bf4bec1030f70026e34dfbd69ad5 824 M README.md' }
-
- it 'initialize the proper attrs' do
- expect(change.operation).to eq(:modified)
- expect(change.old_path).to eq('README.md')
- expect(change.new_path).to eq('README.md')
- expect(change.blob_id).to be_present
- expect(change.blob_size).to be_present
- end
- end
-
- context 'deleting a file' do
- let(:raw_change) { '60d7a906c2fd9e4509aeb1187b98d0ea7ce827c9 15364 D files/.DS_Store' }
-
- it 'initialize the proper attrs' do
- expect(change.operation).to eq(:deleted)
- expect(change.old_path).to eq('files/.DS_Store')
- expect(change.new_path).to be_nil
- expect(change.blob_id).to be_present
- expect(change.blob_size).to be_present
- end
- end
-end
diff --git a/ruby/spec/lib/gitlab/git/repository_spec.rb b/ruby/spec/lib/gitlab/git/repository_spec.rb
index 4364b8818..962be8fc6 100644
--- a/ruby/spec/lib/gitlab/git/repository_spec.rb
+++ b/ruby/spec/lib/gitlab/git/repository_spec.rb
@@ -200,42 +200,6 @@ describe Gitlab::Git::Repository do # rubocop:disable Metrics/BlockLength
end
end
- describe '#raw_changes_between' do
- let(:changes) { repository.raw_changes_between(old_rev, new_rev) }
-
- context 'initial commit' do
- let(:old_rev) { Gitlab::Git::BLANK_SHA }
- let(:new_rev) { '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863' }
-
- it 'returns the changes' do
- expect(changes).to be_present
- expect(changes.size).to eq(3)
- end
- end
-
- context 'with an invalid rev' do
- let(:old_rev) { 'foo' }
- let(:new_rev) { 'bar' }
-
- it 'returns an error' do
- expect { changes }.to raise_error(Gitlab::Git::Repository::GitError)
- end
- end
-
- context 'with valid revs' do
- let(:old_rev) { 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6' }
- let(:new_rev) { '4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6' }
-
- it 'returns the changes' do
- expect(changes.size).to eq(9)
- expect(changes.first.operation).to eq(:modified)
- expect(changes.first.new_path).to eq('.gitmodules')
- expect(changes.last.operation).to eq(:added)
- expect(changes.last.new_path).to eq('files/lfs/picture-invalid.png')
- end
- end
- end
-
describe '#merge_base' do
where(:from, :to, :result) do
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d' | '40f4a7a617393735a95a0bb67b08385bc1e7c66d' | '570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
@@ -764,42 +728,6 @@ describe Gitlab::Git::Repository do # rubocop:disable Metrics/BlockLength
end
end
- describe '#parse_raw_diff_line' do
- let(:diff_data) { repository.parse_raw_diff_line(diff_line) }
-
- context 'valid diff line' do
- let(:diff_line) { ":100644 100644 454bade 2b75299 M\tmodified-file.txt" }
-
- it 'returns the diff data' do
- expect(diff_data).to eq(["100644", "100644", "2b75299", "M\tmodified-file.txt"])
- end
-
- context 'added file' do
- let(:diff_line) { ":000000 100644 0000000 5579569 A\tnew-file.txt" }
-
- it 'returns the new blob id' do
- expect(diff_data[2]).to eq('5579569')
- end
- end
-
- context 'deleted file' do
- let(:diff_line) { ":100644 000000 26b5bd5 0000000 D\tremoved-file.txt" }
-
- it 'returns the old blob id' do
- expect(diff_data[2]).to eq('26b5bd5')
- end
- end
- end
-
- context 'invalid diff line' do
- let(:diff_line) { '' }
-
- it 'raises an ArgumentError' do
- expect { diff_data }.to raise_error(ArgumentError)
- end
- end
- end
-
describe "#commit_patches" do
let(:repository) { gitlab_git_from_gitaly(new_mutable_test_repo) }
let(:testdata_dir) { File.join(File.dirname(__FILE__), '../../../../../internal/service/operations/testdata') }
diff --git a/ruby/spec/lib/gitlab/version_info_spec.rb b/ruby/spec/lib/gitlab/version_info_spec.rb
deleted file mode 100644
index 8cf95ba33..000000000
--- a/ruby/spec/lib/gitlab/version_info_spec.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-require 'spec_helper'
-
-describe Gitlab::VersionInfo do
- let(:unknown) { described_class.new }
- let(:v0_0_1) { described_class.new(0, 0, 1) }
- let(:v0_1_0) { described_class.new(0, 1, 0) }
- let(:v1_0_0) { described_class.new(1, 0, 0) }
- let(:v1_0_1) { described_class.new(1, 0, 1) }
- let(:v1_1_0) { described_class.new(1, 1, 0) }
- let(:v2_0_0) { described_class.new(2, 0, 0) }
-
- context '>' do
- it { expect(v2_0_0).to be > v1_1_0 }
- it { expect(v1_1_0).to be > v1_0_1 }
- it { expect(v1_0_1).to be > v1_0_0 }
- it { expect(v1_0_0).to be > v0_1_0 }
- it { expect(v0_1_0).to be > v0_0_1 }
- end
-
- context '>=' do
- it { expect(v2_0_0).to be >= described_class.new(2, 0, 0) }
- it { expect(v2_0_0).to be >= v1_1_0 }
- end
-
- context '<' do
- it { expect(v0_0_1).to be < v0_1_0 }
- it { expect(v0_1_0).to be < v1_0_0 }
- it { expect(v1_0_0).to be < v1_0_1 }
- it { expect(v1_0_1).to be < v1_1_0 }
- it { expect(v1_1_0).to be < v2_0_0 }
- end
-
- context '<=' do
- it { expect(v0_0_1).to be <= described_class.new(0, 0, 1) }
- it { expect(v0_0_1).to be <= v0_1_0 }
- end
-
- context '==' do
- it { expect(v0_0_1).to eq(described_class.new(0, 0, 1)) }
- it { expect(v0_1_0).to eq(described_class.new(0, 1, 0)) }
- it { expect(v1_0_0).to eq(described_class.new(1, 0, 0)) }
- end
-
- context '!=' do
- it { expect(v0_0_1).not_to eq(v0_1_0) }
- end
-
- context 'unknown' do
- it { expect(unknown).not_to be v0_0_1 }
- it { expect(unknown).not_to be described_class.new }
- it { expect { unknown > v0_0_1 }.to raise_error(ArgumentError) }
- it { expect { unknown < v0_0_1 }.to raise_error(ArgumentError) }
- end
-
- context 'parse' do
- it { expect(described_class.parse("1.0.0")).to eq(v1_0_0) }
- it { expect(described_class.parse("1.0.0.1")).to eq(v1_0_0) }
- it { expect(described_class.parse("git 1.0.0b1")).to eq(v1_0_0) }
- it { expect(described_class.parse("git 1.0b1")).not_to be_valid }
- end
-
- context 'to_s' do
- it { expect(v1_0_0.to_s).to eq("1.0.0") }
- it { expect(unknown.to_s).to eq("Unknown") }
- end
-end