Class: GGem::GitRepo
- Inherits:
-
Object
- Object
- GGem::GitRepo
- Defined in:
- lib/ggem/git_repo.rb
Constant Summary collapse
- NotFoundError =
Class.new(ArgumentError)
- CmdError =
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(repo_path) ⇒ GitRepo
constructor
A new instance of GitRepo.
- #run_add_version_tag_cmd(version, tag) ⇒ Object
- #run_init_cmd ⇒ Object
- #run_push_cmd ⇒ Object
- #run_rm_tag_cmd(tag) ⇒ Object
- #run_validate_clean_cmd ⇒ Object
- #run_validate_committed_cmd ⇒ Object
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.(repo_path)) end |
Instance Attribute Details
#path ⇒ Object (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_cmd ⇒ Object
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_cmd ⇒ Object
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_cmd ⇒ Object
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_cmd ⇒ Object
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 |