class Object

Public Instance Methods

changed_in_git(filename) click to toggle source
# File lib/projectdx_pipeline/capistrano/git_revision.rb, line 13
def changed_in_git(filename)
  `git diff --name-only`.grep(/^#{filename}$/).length > 0 ? true : false
end
commit_in_remote_branch?(commit,branch) click to toggle source
# File lib/projectdx_pipeline/capistrano/git_revision.rb, line 23
def commit_in_remote_branch?(commit,branch)
  return false if commit.nil?
  if  %x{git branch -r --contains #{commit}}.grep(/^\s*origin\/#{branch}/).empty?
      puts ""
      puts "no rev matches #{commit} in the remote #{branch} branch(es)"
      return false
  end
  true
end
commit_of_rev(branch) click to toggle source
# File lib/projectdx_pipeline/capistrano/git_revision.rb, line 17
def commit_of_rev(branch)
  x=`git rev-parse --revs-only #{branch}`.chomp
  return nil if x.empty?
  return x
end
db_connection() click to toggle source
# File lib/projectdx_pipeline/capistrano/database_configuration.rb, line 22
def db_connection
  fetch(:db_connection, {})
end
dbinfo() click to toggle source
# File lib/projectdx_pipeline/capistrano/database_configuration.rb, line 26
def dbinfo
  @dbinfo ||= db_defaults.merge(db_connection)
  unless stage == 'production'
    @dbinfo['database'] = '%s-%s' % [db_name, stage]
  end
  @dbinfo
end
remote_branch_name(branch) click to toggle source

returns the actual branch name, if it exists. nil if it does not

# File lib/projectdx_pipeline/capistrano/git_revision.rb, line 42
def remote_branch_name(branch)
  return nil if branch.nil?
  rem_branch = `git branch -r`.grep(/^\s*origin\/(v|)#{branch}$/)[0]
  return nil if rem_branch.nil?
  return rem_branch.sub(/^\s*origin\//, '').chomp
end
run_with_password(cmd, pwd) click to toggle source
# File lib/projectdx_pipeline/capistrano/database_configuration.rb, line 34
def run_with_password(cmd, pwd)
  once = false
  run cmd do |ch, stream, data|
    $stdout.write(data)
    unless once
      ch.send_data pwd + "\n"
      $stdout.write('[not shown]')
      once = true
    end
  end
end
stage() click to toggle source
# File lib/projectdx_pipeline/capistrano/git_revision.rb, line 9
def stage
  variables[:stage] && variables[:stage].to_s
end
valid_commit?(commit) click to toggle source
# File lib/projectdx_pipeline/capistrano/git_revision.rb, line 33
def valid_commit?(commit)
  return false if commit.nil?
  if branch_stages.include? stage.to_s
    return false unless commit_in_remote_branch?(commit,fetch(:deploy_branch, stage.to_s))
  end
  return true
end
with_tempfile_on_remote_server() { |tempfile_name| ... } click to toggle source
# File lib/projectdx_pipeline/capistrano/database_configuration.rb, line 14
def with_tempfile_on_remote_server(&block)
  tempfile_name = capture('mktemp -t preparedb.XXXXXXXX').strip

  yield tempfile_name
ensure
  run "rm #{tempfile_name}"
end