Module: HerokuSan::Git
Defined Under Namespace
Classes: NoTagFoundError
Instance Method Summary collapse
- #git_active_branch ⇒ Object
- #git_clone(repos, dir) ⇒ Object
- #git_named_rev(ref) ⇒ Object
- #git_parsed_tag(tag) ⇒ Object
- #git_push(commit, repo, options = []) ⇒ Object
- #git_rev_parse(ref) ⇒ Object
- #git_revision(repo) ⇒ Object
- #git_tag(glob) ⇒ Object
Instance Method Details
#git_active_branch ⇒ Object
14 15 16 |
# File 'lib/heroku_san/git.rb', line 14 def git_active_branch %x{git branch}.split("\n").select { |b| b =~ /^\*/ }.first.split(" ").last.strip end |
#git_clone(repos, dir) ⇒ Object
10 11 12 |
# File 'lib/heroku_san/git.rb', line 10 def git_clone(repos, dir) sh "git clone #{repos} #{dir}" end |
#git_named_rev(ref) ⇒ Object
47 48 49 |
# File 'lib/heroku_san/git.rb', line 47 def git_named_rev(ref) %x{git name-rev #{ref}}.chomp end |
#git_parsed_tag(tag) ⇒ Object
29 30 31 |
# File 'lib/heroku_san/git.rb', line 29 def git_parsed_tag(tag) git_rev_parse(git_tag(tag)) end |
#git_push(commit, repo, options = []) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/heroku_san/git.rb', line 18 def git_push(commit, repo, = []) commit ||= "HEAD" ||= [] begin sh "git update-ref refs/heroku_san/deploy #{commit}^{commit}" sh "git push #{repo} #{.join(' ')} refs/heroku_san/deploy:refs/heads/master" ensure sh "git update-ref -d refs/heroku_san/deploy" end end |
#git_rev_parse(ref) ⇒ Object
33 34 35 36 |
# File 'lib/heroku_san/git.rb', line 33 def git_rev_parse(ref) return nil if ref.nil? %x{git rev-parse #{ref}}.split("\n").first end |
#git_revision(repo) ⇒ Object
43 44 45 |
# File 'lib/heroku_san/git.rb', line 43 def git_revision(repo) %x{git ls-remote --heads #{repo} master}.split.first end |
#git_tag(glob) ⇒ Object
38 39 40 41 |
# File 'lib/heroku_san/git.rb', line 38 def git_tag(glob) return nil if glob.nil? %x{git tag -l '#{glob}'}.split("\n").last || (raise NoTagFoundError, "No tag found [#{glob}]") end |