Module: GGSM::Finish

Includes:
Submodule
Included in:
Cli
Defined in:
lib/ggsm/command/finish.rb

Instance Method Summary collapse

Methods included from Submodule

#check_submodule, #check_submodule_status, #check_un_commit_code, #correct_dir, #foreach_module, #get_current_branch, #get_modified_submodule, #get_submodule, #get_submodule_commit, #tip_contact_author

Methods included from Hooks

#check_hooks, #cp_files, #cp_hooks, #update_hooks

Instance Method Details

#finish_flow(force) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ggsm/command/finish.rb', line 8

def finish_flow(force)
  check_submodule

  foreach_module {
    process_finish(false)
  }

  puts '==> 进入主工程:'.yellow
  process_finish(force)

  puts 'Modules执行:git add & commit & push'.blue
end

#process_finish(force) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ggsm/command/finish.rb', line 21

def process_finish(force)
  system 'git add .'

  branch = get_current_branch
  if branch.include?('rebas')
    system 'git rebase --continue'
  else
    stage = `git diff --cached --name-only`.strip
    if stage == ''
      `git commit`
    else
      result = system 'git commit'
      unless result
        exit 1
      end
    end
  end

  `git push -u origin #{get_current_branch} #{force ? '-f' : ''}`
end