Skip to content

Is git rev-parse supported? #530

Closed
Closed
@aubreyyan

Description

@aubreyyan

Is git rev-parse supported?

See https://git-scm.com/docs/git-rev-parse

I see the following line

ruby-git/lib/git/base.rb

Lines 571 to 580 in 765df7c

# runs git rev-parse to convert the objectish to a full sha
#
# @example
# git.revparse("HEAD^^")
# git.revparse('v2.4^{tree}')
# git.revparse('v2.4:/doc/index.html')
#
def revparse(objectish)
self.lib.revparse(objectish)
end

but it's not really well documented.

And when I run an example code I get NoMethodError

irb(main):062:0> Git::Base.new.revparse('HEAD^^')
Traceback (most recent call last):
        9: from /local/workplace/aubreyya/EC2-ZIM-JlbRelayConfigUpdater/env/EC2-ZIM-JlbRelayConfigUpdater-1.0/runtime/bin/../ruby2.7.x/bin/irb:30:in `<main>'
        8: from /local/workplace/aubreyya/EC2-ZIM-JlbRelayConfigUpdater/env/EC2-ZIM-JlbRelayConfigUpdater-1.0/runtime/bin/../ruby2.7.x/bin/irb:30:in `load'
        7: from /local/workplace/aubreyya/EC2-ZIM-JlbRelayConfigUpdater/env/EC2-ZIM-JlbRelayConfigUpdater-1.0/runtime/ruby2.7.x/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        6: from (irb):61
        5: from (irb):62:in `rescue in irb_binding'
        4: from /local/home/aubreyya/brazil-pkg-cache/packages/RubyGem-git/RubyGem-git-1.5.x.1579.0/AL2_x86_64/DEV.STD.PTHREAD/build/ruby2.7.x/lib/ruby/gems/2.7.0/gems/git-1.5.0/lib/git/base.rb:533:in `revparse'
        3: from /local/home/aubreyya/brazil-pkg-cache/packages/RubyGem-git/RubyGem-git-1.5.x.1579.0/AL2_x86_64/DEV.STD.PTHREAD/build/ruby2.7.x/lib/ruby/gems/2.7.0/gems/git-1.5.0/lib/git/base.rb:184:in `lib'
        2: from /local/home/aubreyya/brazil-pkg-cache/packages/RubyGem-git/RubyGem-git-1.5.x.1579.0/AL2_x86_64/DEV.STD.PTHREAD/build/ruby2.7.x/lib/ruby/gems/2.7.0/gems/git-1.5.0/lib/git/base.rb:184:in `new'
        1: from /local/home/aubreyya/brazil-pkg-cache/packages/RubyGem-git/RubyGem-git-1.5.x.1579.0/AL2_x86_64/DEV.STD.PTHREAD/build/ruby2.7.x/lib/ruby/gems/2.7.0/gems/git-1.5.0/lib/git/lib.rb:19:in `initialize'
NoMethodError (undefined method `path' for nil:NilClass)

Edit: okay I see my problem

# Instead of creating a Git::Base directly, obtain a Git::Base instance by
# calling one of the follow {Git} class methods: {Git.open}, {Git.init},
# {Git.clone}, or {Git.bare}.

However it would be nice to have revparse documented here

Your environment

  • RubyGem-git = 1.5.x;
  • git version 2.30.1 (Apple Git-130)
  • ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]

Steps to reproduce

n/a

Expected behaviour

n/a

Actual behaviour

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions