module BbDeploy::Git

Public Class Methods

check_git_status!() click to toggle source
# File lib/bb_deploy/git.rb, line 34
def check_git_status! # rubocop:disable Metrics/CyclomaticComplexity
  puts "Running `git fetch` ... "
  quietly { `git fetch` }
  if `git log ..origin/#{current_branch}`.present?
    exit(0) unless BbDeploy::Task.ask("There are new commits on the remote branch 'origin/#{current_branch}'. Are you sure you want to proceed?")
  end
  status_msg_a = `git status`.split(/(?:\n+)/)
  if status_msg_a[1] =~ /your.branch.is.ahead/i
    exit(0) unless BbDeploy::Task.ask("You have local, committed changes that have not been pushed to the remote.  Are you sure you want to proceed?")
  end
  unless status_msg_a.last =~ /nothing to commit/i
    exit(0) unless BbDeploy::Task.ask("You have local, uncommitted changes.  Are you sure you want to proceed?")
  end
end
current_branch(reload = false) click to toggle source

NOTE - THE DEFAULT AUTO-MEMOIZATION CAN CAUSE ISSUES IF YOU FORGET IT’S HAPPENING, SO NOTE THAT IT OCCURS!!!

# File lib/bb_deploy/git.rb, line 6
def current_branch(reload = false)
  if reload || !@current_branch
    # I don't know sed at all, hence I don't know which backslashes need to be doubled and which don't :(
    cmd = 'git branch 2> /dev/null | sed -e \'/^[^*]/d\' -e \'s/* \(.*\)/\1/\''
    result = `#{cmd}`
    raise "Unable to determine the current branch name" if result.blank?
    @current_branch = result.strip
  else
    @current_branch
  end
end
local_release(branch_name) click to toggle source
# File lib/bb_deploy/git.rb, line 53
def local_release(branch_name)
  `git branch --list "#{branch_name}"`
end
migrations_present?(sha) click to toggle source
# File lib/bb_deploy/git.rb, line 49
def migrations_present?(sha)
  `git diff #{sha} db/migrate`.present?
end
on_a_release_branch?() click to toggle source
# File lib/bb_deploy/git.rb, line 30
def on_a_release_branch?
  current_branch.start_with?('release_')
end
on_master?() click to toggle source
# File lib/bb_deploy/git.rb, line 22
def on_master?
  current_branch == 'master'
end
push_release_branch!() click to toggle source
# File lib/bb_deploy/git.rb, line 26
def push_release_branch!
  puts `git checkout -lb #{new_branch} && git push origin #{new_branch} -u`
end
push_to_phase(phase) click to toggle source
# File lib/bb_deploy/git.rb, line 18
def push_to_phase(phase)
  `git push #{phase} HEAD:master --force`
end
remote_release(branch_name) click to toggle source
# File lib/bb_deploy/git.rb, line 57
def remote_release(branch_name)
  `git branch -r --list "origin/#{branch_name}"`
end