Class: GGem::GitRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/ggem/git_repo.rb

Constant Summary collapse

NotFoundError =
Class.new(ArgumentError)
CmdError =
Class.new(RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_path) ⇒ GitRepo

Returns a new instance of GitRepo.



14
15
16
# File 'lib/ggem/git_repo.rb', line 14

def initialize(repo_path)
  @path = Pathname.new(File.expand_path(repo_path))
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



12
13
14
# File 'lib/ggem/git_repo.rb', line 12

def path
  @path
end

Instance Method Details

#run_add_version_tag_cmd(version, tag) ⇒ Object



38
39
40
# 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_cmdObject



18
19
20
21
22
# 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_cmdObject



32
33
34
35
36
# 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) ⇒ Object



42
43
44
# File 'lib/ggem/git_repo.rb', line 42

def run_rm_tag_cmd(tag)
  run_cmd("git tag -d #{tag}")
end

#run_validate_clean_cmdObject



24
25
26
# File 'lib/ggem/git_repo.rb', line 24

def run_validate_clean_cmd
  run_cmd("git diff --exit-code")
end

#run_validate_committed_cmdObject



28
29
30
# File 'lib/ggem/git_repo.rb', line 28

def run_validate_committed_cmd
  run_cmd("git diff-index --quiet --cached HEAD")
end