class GGem::GitRepo

Constants

CmdError
NotFoundError

Attributes

path[R]

Public Class Methods

new(repo_path) click to toggle source
# File lib/ggem/git_repo.rb, line 14
def initialize(repo_path)
  @path = Pathname.new(File.expand_path(repo_path))
end

Public Instance Methods

run_add_version_tag_cmd(version, tag) click to toggle source
# File lib/ggem/git_repo.rb, line 38
def run_add_version_tag_cmd(version, tag)
  run_cmd("git tag -a -m \"Version #{version}\" #{tag}")
end
run_init_cmd() click to toggle source
# File lib/ggem/git_repo.rb, line 18
def run_init_cmd
  run_cmd("git init").tap do
    run_cmd("git add --all && git add -f *.keep")
  end
end
run_push_cmd() click to toggle source
# File lib/ggem/git_repo.rb, line 32
def run_push_cmd
  run_cmd("git push").tap do
    run_cmd("git push --tags")
  end
end
run_rm_tag_cmd(tag) click to toggle source
# File lib/ggem/git_repo.rb, line 42
def run_rm_tag_cmd(tag)
  run_cmd("git tag -d #{tag}")
end
run_validate_clean_cmd() click to toggle source
# File lib/ggem/git_repo.rb, line 24
def run_validate_clean_cmd
  run_cmd("git diff --exit-code")
end
run_validate_committed_cmd() click to toggle source
# File lib/ggem/git_repo.rb, line 28
def run_validate_committed_cmd
  run_cmd("git diff-index --quiet --cached HEAD")
end

Private Instance Methods

run_cmd(cmd_string) click to toggle source
# File lib/ggem/git_repo.rb, line 48
def run_cmd(cmd_string)
  cmd_string = "cd #{@path} && #{cmd_string}"
  cmd = Scmd.new(cmd_string)
  cmd.run
  unless cmd.success?
    raise CmdError, "#{cmd_string}\n" \
                    "#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}"
  end
  [cmd_string, cmd.exitstatus, cmd.stdout]
end