class GitPlus::Commands::RevParse

A Git rev-parse command wrapper.

Public Class Methods

new(shell: Open3) click to toggle source
# File lib/git_plus/commands/rev_parse.rb, line 9
def initialize shell: Open3
  @shell = shell
end

Public Instance Methods

call(*arguments) click to toggle source
# File lib/git_plus/commands/rev_parse.rb, line 13
  def call(*arguments) = shell.capture3("git", "rev-parse", *arguments)

  def directory?
    call("--git-dir").then do |stdout, _stderr, status|
      status.success? && stdout.chomp == ".git"
    end
  end

  private

  attr_reader :shell
end
directory?() click to toggle source
# File lib/git_plus/commands/rev_parse.rb, line 15
def directory?
  call("--git-dir").then do |stdout, _stderr, status|
    status.success? && stdout.chomp == ".git"
  end
end