-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement porcelain describe #55
Implement porcelain describe #55
Conversation
199f0bd
to
b5d64d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @betesh for the PR! We're happy with the help and will be happy to add Porcelain.describe
. A few points still to address though, see the review remarks.
lib/rjgit.rb
Outdated
options = {:always => false, :long => false, :tags => false}.merge(options) | ||
repo = RJGit.repository_type(repository) | ||
git = RubyGit.new(repo).jgit | ||
git.describe.set_target(ref).set_always(options[:always]).set_long(options[:long]).set_tags(options[:tags]).call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line (ending in .call
) should be wrapped in a begin rescue end
block and rescue the exceptions that DescribeCommand
can throw (i.e., MissingObjectException, IncorrectObjectTypeException, RefNotFoundException, IOException).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how should it handle those exceptions? return nil? raise a Ruby exception of some type (what type)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning nil
would be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
spec/rjgit_spec.rb
Outdated
@@ -170,6 +170,11 @@ | |||
end | |||
end | |||
|
|||
it "mimics git-describe" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add tests for negative cases (wrong input, or no no names found
, etc.).
Regarding |
@dometto It seems like your implementation is much more straightforward? Why not just copy-and-paste it into this repo? (I don't mind writing a few tests, but as far as the code itself, it makes more sense to me for you to push the commit and keep your name on it than for me to paste it and attribute you, especially considering that your LICENSE is empty.) |
@betesh I'm fine with using the code from the adapter to implement grep, since JGit doesn't have its own We should add a LICENSE file for sure, but I am not really worried about the attribution, especially since some lines in the snippet would have to be changed/removed anyway (thinking of the |
I'm okay with using the adapter code as a basis for the actual implementation. 👍 |
@bartkamphorst Do you want to merge this and then I'll tackle grep in a separate PR? |
I have one more suggestion for a minor refactoring, but otherwise it's looking good. Tackling grep in a separate PR is the right way to go. Thanks! 👍 |
I intend to implement
grep
as well, following https://stackoverflow.com/questions/15572483/how-to-do-git-grep-e-pattern-with-jgit/16263886#16263886.It's going to be more work than
describe
was, so before I move forward, could a maintainer please tell me 1) whether the project would accept such an addition? and 2) whether it should be on a separate branch?Thank you!