Module: RuVim::Git

Defined in:
lib/ruvim/git/log.rb,
lib/ruvim/git/diff.rb,
lib/ruvim/git/grep.rb,
lib/ruvim/git/blame.rb,
lib/ruvim/git/branch.rb,
lib/ruvim/git/commit.rb,
lib/ruvim/git/status.rb,
lib/ruvim/git/handler.rb

Defined Under Namespace

Modules: Blame, Branch, Commit, Diff, Grep, Handler, Log, Status

Class Method Summary collapse

Class Method Details

.repo_root(file_path) ⇒ Object

Find git repository root from a file path. Returns [root_path, error_message].



11
12
13
14
15
16
17
18
# File 'lib/ruvim/git/handler.rb', line 11

def repo_root(file_path)
  dir = File.directory?(file_path) ? file_path : File.dirname(file_path)
  out, err, status = Open3.capture3("git", "rev-parse", "--show-toplevel", chdir: dir)
  unless status.success?
    return [nil, err.strip]
  end
  [out.strip, nil]
end