Skip to content

Commit

Permalink
Merge 7cfe77d into d718812
Browse files Browse the repository at this point in the history
  • Loading branch information
betesh committed Apr 30, 2020
2 parents d718812 + 7cfe77d commit 4835774
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/rjgit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ def self.diff(repository, options = {})
RJGit.convert_diff_entries(diff_entries)
end

def self.describe(repository, ref, options = {})
options = {:always => false, :long => false, :tags => false, :match => []}.merge(options)
repo = RJGit.repository_type(repository)
git = RubyGit.new(repo).jgit
command = git.describe.
set_target(ref).
set_always(options[:always]).
set_long(options[:long]).
set_tags(options[:tags])
command = options[:match].each_with_object(command) do |match|
command.set_match(match)
end
command.call
end
end

module Plumbing
Expand Down
15 changes: 15 additions & 0 deletions spec/rjgit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@
end
end

describe 'git-describe' do
it "mimics git-describe" do
id = Porcelain.commit(@repo, "Initial commit").id
expect(Porcelain.describe(@repo, id)).to match(/\Av0\.0-2-g[0-9a-f]{7}\z/)
end

it "matches the right tag when match is used" do
@repo.git.tag('v0.1', 'Tag v0.1', Porcelain.commit(@repo, "Previous commit").id)
id = Porcelain.commit(@repo, "Initial commit").id
expect(Porcelain.describe(@repo, id, match: ['v0.0'])).to match(/\Av0\.0-4-g[0-9a-f]{7}\z/)
expect(Porcelain.describe(@repo, id, match: ['v0.1'])).to match(/\Av0\.1-1-g[0-9a-f]{7}\z/)
expect(Porcelain.describe(@repo, id, match: ['v0.0', 'v0.1'])).to match(/\Av0\.1-1-g[0-9a-f]{7}\z/)
end
end

after(:all) do
@repo = nil
remove_temp_repo(@temp_repo_path)
Expand Down

0 comments on commit 4835774

Please sign in to comment.