Sha256: 144b6b20ae8568f273794ce1454007977212cc68c39e937646f7cd830dd348a7

Contents?: true

Size: 894 Bytes

Versions: 3

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

require "open3"
require "rfix"
require "rfix/log"
require "rfix/cmd"

module Rfix::GitHelper
  include Rfix::Log
  include Rfix::Cmd

  def git(*args, root: Dir.pwd, quiet: false, &block)
    args.unshift *["--git-dir", File.join(root, ".git")]
    args.unshift *["--work-tree", root]
    cmd("git", *args, quiet: quiet, &block)
  end

  def has_branch?(branch)
    cmd_succeeded?("git", "cat-file", "-t", branch)
  end

  def dirty?(path)
    Dir.chdir(path) do
      !cmd_succeeded?("git diff --quiet")
    end
  end

  def params
    [
      "--word-diff-regex=[^[:space:]]",
      "--no-renames",
      "--no-merges",
      "--first-parent",
      "--find-renames",
      "--find-copies",
      "--diff-filter=AMCR",
      "-U0",
      "--no-color",
      "-p"
    ]
  end
end

# TODO: Rename above to just ::Git
module Rfix::Git
  extend Rfix::GitHelper
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rfix-1.0.15.pre.116 lib/rfix/git_helper.rb
rfix-1.0.15 lib/rfix/git_helper.rb
rfix-1.0.8.pre.109 lib/rfix/git_helper.rb