class GitProc::Process

Public Class Methods

new(gitlib, opts = {}) click to toggle source

@param [GitLib] gitlib

# File lib/git-process/git_process.rb, line 24
def initialize(gitlib, opts = {})
  @gitlib = gitlib
end

Public Instance Methods

cleanup() click to toggle source
# File lib/git-process/git_process.rb, line 87
def cleanup
  # extension point
end
config() click to toggle source
# File lib/git-process/git_process.rb, line 63
def config
  gitlib.config
end
fetch_remote_changes(remote_name = nil) click to toggle source
# File lib/git-process/git_process.rb, line 92
def fetch_remote_changes(remote_name = nil)
  gitlib.fetch_remote_changes(remote_name)
end
gitlib() click to toggle source
# File lib/git-process/git_process.rb, line 29
def gitlib
  @gitlib
end
is_parked?() click to toggle source
# File lib/git-process/git_process.rb, line 97
def is_parked?
  gitlib.is_parked?
end
logger() click to toggle source
# File lib/git-process/git_process.rb, line 58
def logger
  gitlib.logger
end
master_branch() click to toggle source
# File lib/git-process/git_process.rb, line 68
def master_branch
  gitlib.config.master_branch
end
remote() click to toggle source
# File lib/git-process/git_process.rb, line 73
def remote
  gitlib.remote
end
run() click to toggle source
# File lib/git-process/git_process.rb, line 34
def run
  begin
    verify_preconditions

    runner
  rescue GitProc::GitProcessError => exp
    puts exp.message
    exit(-1)
  ensure
    cleanup
  end
end
runner() click to toggle source
# File lib/git-process/git_process.rb, line 48
def runner
  # extension point - does nothing by default
end
verify_preconditions() click to toggle source
# File lib/git-process/git_process.rb, line 78
def verify_preconditions
  if should_remove_master?
    if ask_about_removing_master
      delete_master_branch!
    end
  end
end
workdir() click to toggle source
# File lib/git-process/git_process.rb, line 53
def workdir
  gitlib.workdir
end

Private Instance Methods

ask_about_removing_master() click to toggle source
# File lib/git-process/git_process.rb, line 138
def ask_about_removing_master
  resp = ask("You should remove your obsolete <%= color('local', [:bold]) %> branch, '#{config.master_branch}'. Should I remove it for you? (Yn) ") do |q|
    q.responses[:not_valid] = 'Please respond with either (y)es or (n)o. Defaults to (y)es.'
    q.case = :down
    q.default = 'Y'
    q.validate = /y|n/i
  end

  if resp == 'n'
    say("(You can turn off this message using \"git config gitProcess.keepLocalIntegrationBranch true\").")
    false
  else
    true
  end
end
delete_master_branch!() click to toggle source
# File lib/git-process/git_process.rb, line 105
def delete_master_branch!
  gitlib.branches[config.master_branch].delete!
end
keep_local_integration_branch?() click to toggle source
# File lib/git-process/git_process.rb, line 127
def keep_local_integration_branch?
  keep_local_integration_branch_config_value.to_boolean
end
keep_local_integration_branch_config_value() click to toggle source

noinspection RubyInstanceMethodNamingConvention

# File lib/git-process/git_process.rb, line 133
def keep_local_integration_branch_config_value
  gitlib.config['gitProcess.keepLocalIntegrationBranch']
end
proc_merge(base, opts = {}) click to toggle source
# File lib/git-process/git_process.rb, line 160
def proc_merge(base, opts = {})
  gitlib.proc_merge(base, opts)
end
proc_rebase(base, opts = {}) click to toggle source
# File lib/git-process/git_process.rb, line 155
def proc_rebase(base, opts = {})
  gitlib.proc_rebase(base, opts)
end
should_remove_master?() click to toggle source

noinspection RubyLocalVariableNamingConvention

# File lib/git-process/git_process.rb, line 111
def should_remove_master?
  has_a_remote = gitlib.has_a_remote?
  my_branches = gitlib.branches
  includes_master_branch = my_branches.include?(config.master_branch)
  current_branch_is_not_master = my_branches.current.name != config.master_branch
  do_not_keep_integration_branch = !keep_local_integration_branch?
  integration_branch_contains_all_of_master = includes_master_branch and my_branches[config.integration_branch].contains_all_of(config.master_branch)

  return (has_a_remote and
      includes_master_branch and
      current_branch_is_not_master and
      do_not_keep_integration_branch and
      integration_branch_contains_all_of_master)
end