module GitDeploy::Configuration
Private Instance Methods
branch()
click to toggle source
# File lib/git_deploy/configuration.rb, line 21 def branch 'master' end
current_branch()
click to toggle source
# File lib/git_deploy/configuration.rb, line 62 def current_branch git_config['symbolic-ref -q HEAD'] end
git_config()
click to toggle source
# File lib/git_deploy/configuration.rb, line 25 def git_config @git_config ||= Hash.new do |cache, cmd| git = ENV['GIT'] || 'git' out = `#{git} #{cmd}` if $?.success? then cache[cmd] = out.chomp else cache[cmd] = nil end cache[cmd] end end
normalize_branch(branch)
click to toggle source
# File lib/git_deploy/configuration.rb, line 71 def normalize_branch(branch) branch.sub('refs/heads/', '') end
remote_for(branch)
click to toggle source
# File lib/git_deploy/configuration.rb, line 75 def remote_for(branch) git_config['config branch.%s.remote' % normalize_branch(branch)] end
remote_url(remote = options[:remote])
click to toggle source
# File lib/git_deploy/configuration.rb, line 42 def remote_url(remote = options[:remote]) @remote_url ||= {} @remote_url[remote] ||= begin url = remote_urls(remote).first if url.nil? abort "Error: Remote url not found for remote #{remote.inspect}" elsif url =~ /(^|@)github\.com\b/ abort "Error: Remote url for #{remote.inspect} points to GitHub. Can't deploy there!" else url = 'ssh://' + url.sub(%r{:/?}, '/') unless url =~ %r{^[\w-]+://} begin url = URI.parse url rescue abort "Error parsing remote url #{url}" end end url end end
remote_urls(remote)
click to toggle source
# File lib/git_deploy/configuration.rb, line 36 def remote_urls(remote) git_config["remote -v"].to_s.split("\n"). select {|l| l =~ /^#{remote}\t.+/ }. map {|l| l.split("\t")[1].sub(/\s+\(.+?\)$/, '') } end
remote_user()
click to toggle source
# File lib/git_deploy/configuration.rb, line 14 def remote_user @user ||= begin user = remote_url.user user ? CGI.unescape(user) : `whoami`.chomp end end
tracked_branch()
click to toggle source
# File lib/git_deploy/configuration.rb, line 66 def tracked_branch branch = current_branch && tracked_for(current_branch) normalize_branch(branch) if branch end
tracked_for(branch)
click to toggle source
# File lib/git_deploy/configuration.rb, line 79 def tracked_for(branch) git_config['config branch.%s.merge' % normalize_branch(branch)] end