Skip to content

Is git rev-parse supported? #530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aubreyyan opened this issue Jul 13, 2021 · 1 comment
Closed

Is git rev-parse supported? #530

aubreyyan opened this issue Jul 13, 2021 · 1 comment

Comments

@aubreyyan
Copy link

aubreyyan commented Jul 13, 2021

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

@jcouball
Copy link
Member

jcouball commented Jan 3, 2022

Documentation for Git::Base#revparse was added in PR #502. View it here:
https://rubydoc.info/gems/git/Git/Base#revparse-instance_method

@jcouball jcouball closed this as completed Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants