Class: VersionManager::VCS::Git
- Inherits:
-
Object
- Object
- VersionManager::VCS::Git
- Defined in:
- lib/version-manager/vcs/git.rb
Instance Method Summary collapse
- #add_tag(tag_name, message) ⇒ Object
- #checkout(branch_name) ⇒ Object
- #commit(filepath, message) ⇒ Object
- #create_branch!(branch_name) ⇒ Object
- #current_branch ⇒ Object
-
#initialize(options) ⇒ Git
constructor
A new instance of Git.
- #master_state_actual? ⇒ Boolean
- #push ⇒ Object
- #push_tag(tag_name) ⇒ Object
- #remote_branch_names ⇒ Object
- #show_file(branch, filepath) ⇒ Object
- #state_actual? ⇒ Boolean
-
#switch_branch(branch_name) ⇒ Object
checkout moves commits to new branch.
Constructor Details
Instance Method Details
#add_tag(tag_name, message) ⇒ Object
33 34 35 |
# File 'lib/version-manager/vcs/git.rb', line 33 def add_tag(tag_name, ) git.add_tag(tag_name, message: , annotate: tag_name) end |
#checkout(branch_name) ⇒ Object
14 15 16 |
# File 'lib/version-manager/vcs/git.rb', line 14 def checkout(branch_name) git.branch(branch_name).checkout end |
#commit(filepath, message) ⇒ Object
28 29 30 31 |
# File 'lib/version-manager/vcs/git.rb', line 28 def commit(filepath, ) git.lib.send(:command, 'add', filepath) git.lib.send(:command, 'commit', "-m #{}", '-o', "#{filepath}") end |
#create_branch!(branch_name) ⇒ Object
9 10 11 12 |
# File 'lib/version-manager/vcs/git.rb', line 9 def create_branch!(branch_name) raise VersionManager::VCS::BranchAlreadyExistsError.new(branch_name) if branch_exists?(branch_name) checkout(branch_name) end |
#current_branch ⇒ Object
46 47 48 |
# File 'lib/version-manager/vcs/git.rb', line 46 def current_branch git.current_branch end |
#master_state_actual? ⇒ Boolean
50 51 52 |
# File 'lib/version-manager/vcs/git.rb', line 50 def master_state_actual? git.revparse(master_branch_name) == git.revparse(remote_master_branch_name) end |
#push ⇒ Object
37 38 39 40 |
# File 'lib/version-manager/vcs/git.rb', line 37 def push git.pull(remote, current_branch) if find_remote_branch(current_branch) git.push(remote, current_branch) end |
#push_tag(tag_name) ⇒ Object
42 43 44 |
# File 'lib/version-manager/vcs/git.rb', line 42 def push_tag(tag_name) git.push(remote, tag_name) end |
#remote_branch_names ⇒ Object
61 62 63 |
# File 'lib/version-manager/vcs/git.rb', line 61 def remote_branch_names ::Git.ls_remote['remotes'].keys end |
#show_file(branch, filepath) ⇒ Object
22 23 24 25 26 |
# File 'lib/version-manager/vcs/git.rb', line 22 def show_file(branch, filepath) git.object("#{branch}:#{filepath}").contents rescue StandardError nil end |
#state_actual? ⇒ Boolean
54 55 56 57 58 59 |
# File 'lib/version-manager/vcs/git.rb', line 54 def state_actual? head = ::Git.ls_remote['branches'][git.current_branch] remote_head = find_remote_branch(git.current_branch).last return unless remote_head head[:sha] == remote_head[:sha] end |
#switch_branch(branch_name) ⇒ Object
checkout moves commits to new branch
18 19 20 |
# File 'lib/version-manager/vcs/git.rb', line 18 def switch_branch(branch_name) # checkout moves commits to new branch git.lib.send(:command, 'checkout', branch_name) end |