Skip to content
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

Capture standard error when shelling out to git #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davidbalbert
Copy link

find_git_root checks stdout for error messages, but error messages are printed to standard error. Thus we get an exception later on in the code because the error check failed. Here's what currently happens:

[1] pry(main)> git blame Pry.start
fatal: Not a git repository (or any of the parent directories): .git
NoMethodError: undefined method `trees' for nil:NilClass
from /Users/david/Development/pry-git/lib/pry-git.rb:19:in `block in get_file_from_commit'

The "fatal line is git's standard error, the next two lines are from later because of the broken error check.

With this fix, the output becomes:

[1] pry(main)> git blame Pry.start
Error: No git repository found in
/Users/david/.rvm/gems/ruby-1.9.3-p194/gems/pry-0.9.9.6/lib/pry

@davidbalbert
Copy link
Author

I also included a Gemfile because I like to use bundle exec pry to test pry plugins. But I just found about about rake pry so feel free to ignore that commit and just cherry-pick 77cc10d.

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

Successfully merging this pull request may close these issues.

1 participant