Class: GGem::GitRepo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_path) ⇒ GitRepo

Returns a new instance of GitRepo.



10
11
12
# File 'lib/ggem/git_repo.rb', line 10

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/ggem/git_repo.rb', line 8

def path
  @path
end

Instance Method Details

#run_add_version_tag_cmd(version, tag) ⇒ Object



34
35
36
# File 'lib/ggem/git_repo.rb', line 34

def run_add_version_tag_cmd(version, tag)
  run_cmd("git tag -a -m \"Version #{version}\" #{tag}")
end

#run_init_cmdObject



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

def run_init_cmd
  run_cmd("git init").tap do
    run_cmd("git add --all && git add -f *.gitkeep")
  end
end

#run_push_cmdObject



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

def run_push_cmd
  run_cmd("git push").tap do
    run_cmd("git push --tags")
  end
end

#run_rm_tag_cmd(tag) ⇒ Object



38
39
40
# File 'lib/ggem/git_repo.rb', line 38

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

#run_validate_clean_cmdObject



20
21
22
# File 'lib/ggem/git_repo.rb', line 20

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

#run_validate_committed_cmdObject



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

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