We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8ccbb1a commit 77cc10dCopy full SHA for 77cc10d
lib/pry-git.rb
@@ -6,6 +6,7 @@
6
require 'grit'
7
require 'diffy'
8
require 'tempfile'
9
+require 'open3'
10
11
module PryGit
12
module GitHelpers
@@ -36,12 +37,13 @@ def relative_path(root, path)
36
37
38
# return the git top level for a given directory
39
def find_git_root(dir)
- git_root = "."
40
+ git_root = nil
41
Dir.chdir dir do
- git_root = `git rev-parse --show-toplevel`.chomp
42
+ git_root, _ = Open3.capture2e("git rev-parse --show-toplevel")
43
+ git_root = git_root.chomp
44
end
45
- raise "No associated git repository found!" if git_root =~ /fatal:/
46
+ raise Pry::CommandError, "No git repository found in #{dir}" if git_root =~ /fatal:/
47
git_root
48
49
0 commit comments