Module: Commands::Git
- Included in:
- Heroploy::CheckTaskLib, Heroploy::EnvTaskLib
- Defined in:
- lib/heroploy/commands/git.rb
Instance Method Summary collapse
- #current_branch ⇒ Object
- #git_fetch ⇒ Object
- #git_push_tag(tag) ⇒ Object
- #git_push_to_master(remote, local_branch) ⇒ Object
- #git_remote_behind?(remote, remote_branch_name, local_branch_name = nil) ⇒ Boolean
- #git_remote_exists?(name) ⇒ Boolean
- #git_remote_has_branch?(remote, branch_name) ⇒ Boolean
- #git_staged?(remote, local_branch) ⇒ Boolean
- #git_tag(tag, message) ⇒ Object
Instance Method Details
#current_branch ⇒ Object
9 10 11 12 |
# File 'lib/heroploy/commands/git.rb', line 9 def current_branch branch = Shell.eval "git rev-parse --abbrev-ref HEAD" branch.strip end |
#git_fetch ⇒ Object
5 6 7 |
# File 'lib/heroploy/commands/git.rb', line 5 def git_fetch Shell.exec "git fetch" end |
#git_push_tag(tag) ⇒ Object
42 43 44 |
# File 'lib/heroploy/commands/git.rb', line 42 def git_push_tag(tag) Shell.exec("git push origin #{tag}") end |
#git_push_to_master(remote, local_branch) ⇒ Object
14 15 16 17 |
# File 'lib/heroploy/commands/git.rb', line 14 def git_push_to_master(remote, local_branch) if ENV['force'] == 'true' then opts = "--force " end Shell.exec "git push #{opts}#{remote} #{local_branch}:master" end |
#git_remote_behind?(remote, remote_branch_name, local_branch_name = nil) ⇒ Boolean
29 30 31 32 |
# File 'lib/heroploy/commands/git.rb', line 29 def git_remote_behind?(remote, remote_branch_name, local_branch_name = nil) if local_branch_name.nil? then local_branch_name = remote_branch_name end !Shell.eval("git log #{remote}/#{remote_branch_name}..#{local_branch_name}").empty? end |
#git_remote_exists?(name) ⇒ Boolean
19 20 21 22 |
# File 'lib/heroploy/commands/git.rb', line 19 def git_remote_exists?(name) remotes = Shell.eval("git remote").strip.split(/\s+/) remotes.include?(name) end |
#git_remote_has_branch?(remote, branch_name) ⇒ Boolean
24 25 26 27 |
# File 'lib/heroploy/commands/git.rb', line 24 def git_remote_has_branch?(remote, branch_name) branches = Shell.eval("git branch -r").strip.split(/\s+/) branches.include?("#{remote}/#{branch_name}") end |
#git_staged?(remote, local_branch) ⇒ Boolean
34 35 36 |
# File 'lib/heroploy/commands/git.rb', line 34 def git_staged?(remote, local_branch) !git_remote_behind?(remote, 'master', local_branch) end |
#git_tag(tag, message) ⇒ Object
38 39 40 |
# File 'lib/heroploy/commands/git.rb', line 38 def git_tag(tag, ) Shell.exec("git tag -a #{tag} -m \"#{message}\"") end |