Class: Afterlife::Propagate::PropagateQaToSandbox

Inherits:
Object
  • Object
show all
Defined in:
lib/afterlife/propagate/propagate_qa_to_sandbox.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_path = nil) ⇒ PropagateQaToSandbox

Returns a new instance of PropagateQaToSandbox.



10
11
12
13
# File 'lib/afterlife/propagate/propagate_qa_to_sandbox.rb', line 10

def initialize(repo_path = nil)
  @repo_path = repo_path || Afterlife.current_repo.full_path
  @original_branch = nil
end

Class Method Details

.call(repo_path = nil) ⇒ Object



6
7
8
# File 'lib/afterlife/propagate/propagate_qa_to_sandbox.rb', line 6

def self.call(repo_path = nil)
  new(repo_path).call
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/afterlife/propagate/propagate_qa_to_sandbox.rb', line 15

def call
  log_info "Starting QA to Sandbox propagation in #{@repo_path}"

  @original_branch = current_branch
  log_info "Current branch: #{@original_branch}"

  fetch_qa_branch
  switch_to_sandbox
  reset_sandbox_to_qa
  push_sandbox_changes

  log_success 'Successfully propagated QA to Sandbox'

  return_to_original_branch if @original_branch != 'sandbox'
rescue StandardError => e
  log_error "Error during propagation: #{e.message}"
  return_to_original_branch if @original_branch && @original_branch != current_branch
  raise
end