class Object

Public Instance Methods

git_head() click to toggle source
# File lib/mamiya/helpers/git.rb, line 28
def git_head
  git_show = `git show --pretty=fuller -s`
  commit, comment = git_show.split(/\n\n/, 2)

  {
    commit: commit.match(/^commit (.+)$/)[1],
    author: commit.match(/^Author:\s*(?<name>.+?) <(?<email>.+?)>$/).
      tap {|match| break Hash[match.names.map {|name| [name.to_sym, match[name]] }] },
    author_date: Time.parse(commit.match(/^AuthorDate:\s*(.+)$/)[1]),
    committer: commit.match(/^Commit:\s*(?<name>.+?) <(?<email>.+?)>$/).
      tap {|match| break Hash[match.names.map {|name| [name.to_sym, match[name]] }] },
    commit_date: Time.parse(commit.match(/^CommitDate:\s*(.+)$/)[1]),
  }
end
git_ignored_files() click to toggle source
# File lib/mamiya/helpers/git.rb, line 11
def git_ignored_files
  git_clean_out = `git clean -ndx`.lines
  prefix = /^Would (?:remove|skip repository) /

  if git_clean_out.any? { |_| prefix !~ _ }
    puts git_clean_out
    raise "`git clean -ndx` doesn't return line starting with 'Would remove' or 'Would skip'"
  end

  excludes = git_clean_out.grep(prefix).map{ |_| _.sub(prefix, '').chomp }
  if package_under
    excludes.grep(/^#{Regexp.escape(package_under)}/).map{ |_| _.sub(/^#{Regexp.escape(package_under)}\/?/, '') }
  else
    excludes
  end
end
git_managed?() click to toggle source
# File lib/mamiya/helpers/git.rb, line 7
def git_managed?
  system *%w(git rev-parse --git-dir), err: File::NULL, out: File::NULL
end