Class: BigKeeper::StashService

Inherits:
Object
  • Object
show all
Defined in:
lib/big_keeper/service/stash_service.rb

Overview

Operator for got

Instance Method Summary collapse

Instance Method Details

#apply_stash(path, user, branch_name, modules) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/big_keeper/service/stash_service.rb', line 32

def apply_stash(path, user, branch_name, modules)
  # Stash modules
  modules.each do |module_name|
    module_path = BigkeeperParser.module_full_path(path, user, module_name)
    BigStash::StashOperator.new(module_path).apply_stash(branch_name)
  end
  # Stash home
  BigStash::StashOperator.new(path).apply_stash(branch_name)
end

#stash(path, new_branch_name, user, modules) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/big_keeper/service/stash_service.rb', line 8

def stash(path, new_branch_name, user, modules)
  # Stash modules
  modules.each do |module_name|
    module_path = BigkeeperParser.module_full_path(path, user, module_name)
    branch_name = GitOperator.new.current_branch(module_path)

    if branch_name != new_branch_name
      p %Q(Current branch of '#{module_name}' is '#{branch_name}', start to stash...)
      BigStash::StashOperator.new(module_path).stash(branch_name)
    else
      p %Q(Current branch name of '#{module_name}' is the same with new branch, continue...)
    end
  end

  # Stash home
  branch_name = GitOperator.new.current_branch(path)
  if branch_name != new_branch_name
    p %Q(Current branch of home is '#{branch_name}', start to stash...)
    BigStash::StashOperator.new(path).stash(branch_name)
  else
    p "Current branch name of home is the same with new branch, continue..."
  end
end