Class: Versi::Interfaces::GitInterface
- Inherits:
-
Object
- Object
- Versi::Interfaces::GitInterface
- Defined in:
- lib/versi/interfaces/git_interface.rb
Constant Summary collapse
- DEFAULT_REMOTE =
"origin"
- GIT_TAG_LIST_COMMAND =
"git tag --list"
- GIT_FETCH_TAGS_COMMAND =
"git fetch --tags"
- GIT_LAST_COMMIT_MSG_COMMAND =
"git log -1 --pretty=%B"
Instance Method Summary collapse
- #create_branch(branch_name) ⇒ Object
- #create_tag(tag, message = nil) ⇒ Object
- #delete_tag(tag) ⇒ Object
- #delete_tag_remote(tag) ⇒ Object
- #fetch_tags ⇒ Object
-
#initialize(remote: DEFAULT_REMOTE) ⇒ GitInterface
constructor
A new instance of GitInterface.
- #last_commit_message ⇒ Object
- #list_tags ⇒ Object
- #push_tag(tag) ⇒ Object
Constructor Details
#initialize(remote: DEFAULT_REMOTE) ⇒ GitInterface
Returns a new instance of GitInterface.
11 12 13 14 |
# File 'lib/versi/interfaces/git_interface.rb', line 11 def initialize(remote: DEFAULT_REMOTE) remote ||= DEFAULT_REMOTE @remote = remote end |
Instance Method Details
#create_branch(branch_name) ⇒ Object
50 51 52 53 |
# File 'lib/versi/interfaces/git_interface.rb', line 50 def create_branch(branch_name) Versi::LOG.info("Creating branch #{branch_name}.. ") System.call!("git checkout -b #{branch_name}") end |
#create_tag(tag, message = nil) ⇒ Object
16 17 18 19 |
# File 'lib/versi/interfaces/git_interface.rb', line 16 def create_tag(tag, =nil) Versi::LOG.info("Generating git tag \"#{tag}\".. ") System.call!("git tag -a \"#{tag}\" -m \"#{}\"") end |
#delete_tag(tag) ⇒ Object
21 22 23 24 |
# File 'lib/versi/interfaces/git_interface.rb', line 21 def delete_tag(tag) Versi::LOG.info("Deleting git tag \"#{tag}\".. ") System.call!("git tag -d \"#{tag}\"") end |
#delete_tag_remote(tag) ⇒ Object
26 27 28 29 |
# File 'lib/versi/interfaces/git_interface.rb', line 26 def delete_tag_remote(tag) Versi::LOG.info("Deleting git tag \"#{tag}\" on remote (#{@remote}).. ") System.call!("git push #{@remote} --delete \"#{tag}\"") end |
#fetch_tags ⇒ Object
36 37 38 39 |
# File 'lib/versi/interfaces/git_interface.rb', line 36 def Versi::LOG.info("Updating local git tags.. ") System.call!(GIT_FETCH_TAGS_COMMAND) end |
#last_commit_message ⇒ Object
46 47 48 |
# File 'lib/versi/interfaces/git_interface.rb', line 46 def System.call!(GIT_LAST_COMMIT_MSG_COMMAND).stdout.join("\n") end |
#list_tags ⇒ Object
41 42 43 44 |
# File 'lib/versi/interfaces/git_interface.rb', line 41 def response = System.call!(GIT_TAG_LIST_COMMAND) response.stdout end |