class DEIS::Git
Public Class Methods
branch()
click to toggle source
# File lib/rdeis/git.rb, line 34 def self.branch `#{DEIS::Git.branch_cmd}`.strip end
branch_cmd()
click to toggle source
# File lib/rdeis/git.rb, line 38 def self.branch_cmd "git rev-parse --abbrev-ref HEAD" end
checkout_to_ref_cmd(ref, branch)
click to toggle source
# File lib/rdeis/git.rb, line 46 def self.checkout_to_ref_cmd(ref, branch) "git fetch origin && git checkout -f origin/#{branch} && git branch -d #{branch} ; git checkout -f #{branch} && git checkout -f #{ref} 2>&1 | grep 'error:' | wc -l" end
github_token()
click to toggle source
find env based token
# File lib/rdeis/git.rb, line 51 def self.github_token v = self.github_token_varname ENV[v] end
github_token_cmd()
click to toggle source
more advanced version that reads config files
# File lib/rdeis/git.rb, line 57 def self.github_token_cmd "cat #{DEIS::Storage::BASE_PATH}.profile | grep #{DEIS::Git.github_token_varname}=.* -o | sed -E 's##{DEIS::Git.github_token_varname}=##' | sed -E 's#\"##g'" end
github_token_varname()
click to toggle source
# File lib/rdeis/git.rb, line 61 def self.github_token_varname "GITHUB_TOKEN" end
init_with_remote_cmd(remote)
click to toggle source
# File lib/rdeis/git.rb, line 42 def self.init_with_remote_cmd(remote) "git init && git remote add origin #{remote} 2>&1 | grep 'fatal:' -o | wc -l" end
is_git?()
click to toggle source
# File lib/rdeis/git.rb, line 4 def self.is_git? res = `#{DEIS::Git.is_git_cmd}`.to_i if res == 0 then true else false end end
is_git_cmd()
click to toggle source
# File lib/rdeis/git.rb, line 9 def self.is_git_cmd "git status 2>&1 | grep 'fatal: Not a git' | wc -l" end
name()
click to toggle source
# File lib/rdeis/git.rb, line 13 def self.name remote = DEIS::Git.remote if remote.nil? || remote.length == 0 return "na" else `echo #{remote} | grep "/.*\.git" -o | sed -E "s#/##" | sed -E "s#.git##" 2>/dev/null`.strip end end
ref()
click to toggle source
# File lib/rdeis/git.rb, line 26 def self.ref `#{DEIS::Git.ref_cmd}`.strip end
ref_cmd()
click to toggle source
# File lib/rdeis/git.rb, line 30 def self.ref_cmd "git rev-parse --verify HEAD 2>/dev/null" end
remote()
click to toggle source
# File lib/rdeis/git.rb, line 22 def self.remote `c=$(git remote show | wc -l ) ; if [ "$c" -gt 0 ]; then git remote show -n origin | grep " Fetch URL:" | grep ": .*" -o | sed -E "s#: ##" 2>/dev/null ; fi`.strip end