Class: BigKeeper::ModuleService
- Inherits:
-
Object
- Object
- BigKeeper::ModuleService
- Defined in:
- lib/big_keeper/service/module_service.rb
Overview
Operator for got
Instance Method Summary collapse
- #add(path, user, module_name, name, type) ⇒ Object
- #del(path, user, module_name, name, type) ⇒ Object
- #finish(path, user, module_name, home_branch_name, type) ⇒ Object
- #module_info(module_path, home_branch_name, user, type, module_name, version) ⇒ Object
- #pre_publish(path, user, module_name, home_branch_name, type) ⇒ Object
- #publish(path, user, module_name, home_branch_name, type) ⇒ Object
- #pull(path, user, module_name, home_branch_name, type) ⇒ Object
- #push(path, user, module_name, home_branch_name, type, comment) ⇒ Object
- #rebase(path, user, module_name, home_branch_name, type) ⇒ Object
- #switch_to(path, user, module_name, home_branch_name, type) ⇒ Object
Instance Method Details
#add(path, user, module_name, name, type) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/big_keeper/service/module_service.rb', line 111 def add(path, user, module_name, name, type) home_branch_name = "#{GitflowType.name(type)}/#{name}" Logger.highlight("Add branch '#{home_branch_name}' for module '#{module_name}'...") verify_module(path, user, module_name, home_branch_name, type) DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::ADD) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) GitService.new.verify_push(module_full_path, "init #{GitflowType.name(type)} #{name}", home_branch_name, module_name) ModuleCacheOperator.new(path).add_path_module(module_name) end |
#del(path, user, module_name, name, type) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/big_keeper/service/module_service.rb', line 125 def del(path, user, module_name, name, type) home_branch_name = "#{GitflowType.name(type)}/#{name}" Logger.highlight("Delete branch '#{home_branch_name}' for module '#{module_name}'...") module_git = BigkeeperParser.module_git(module_name) DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::DELETE) # Stash module current branch module_full_path = BigkeeperParser.module_full_path(path, user, module_name) current_branch_name = GitOperator.new.current_branch(module_full_path) StashService.new.stash(module_full_path, current_branch_name, module_name) GitOperator.new.checkout(module_full_path, GitflowType.base_branch(type)) ModuleCacheOperator.new(path).del_path_module(module_name) end |
#finish(path, user, module_name, home_branch_name, type) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/big_keeper/service/module_service.rb', line 97 def finish(path, user, module_name, home_branch_name, type) Logger.highlight("Finish branch '#{home_branch_name}' for module '#{module_name}'...") verify_module(path, user, module_name, home_branch_name, type) DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::FINISH) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) GitService.new.verify_push(module_full_path, "finish branch #{home_branch_name}", home_branch_name, module_name) ModuleCacheOperator.new(path).add_git_module(module_name) ModuleCacheOperator.new(path).del_path_module(module_name) end |
#module_info(module_path, home_branch_name, user, type, module_name, version) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/big_keeper/service/module_service.rb', line 142 def module_info(module_path, home_branch_name, user, type, module_name, version) result_dic = {} matched_branches = [] branches = GitService.new.branchs_with_type(module_path, type) if version == 'all versions' matched_branches = branches else branches.each do | branch | matched_branches << branch if branch.include?(version) end end result_dic[:module_name] = module_name result_dic[:current_branch] = GitOperator.new.current_branch(module_path) result_dic[:branches] = matched_branches result_dic end |
#pre_publish(path, user, module_name, home_branch_name, type) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/big_keeper/service/module_service.rb', line 74 def pre_publish(path, user, module_name, home_branch_name, type) Logger.highlight("Prepare to publish branch '#{home_branch_name}' for module '#{module_name}'...") verify_module(path, user, module_name, home_branch_name, type) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) GitService.new.verify_push(module_full_path, "prepare to rebase '#{GitflowType.base_branch(type)}'", home_branch_name, module_name) GitService.new.verify_rebase(module_full_path, GitflowType.base_branch(type), module_name) end |
#publish(path, user, module_name, home_branch_name, type) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/big_keeper/service/module_service.rb', line 84 def publish(path, user, module_name, home_branch_name, type) Logger.highlight("Publish branch '#{home_branch_name}' for module '#{module_name}'...") DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::PUBLISH) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) GitService.new.verify_push(module_full_path, "publish branch #{home_branch_name}", home_branch_name, module_name) `open #{BigkeeperParser.module_pulls(module_name)}` ModuleCacheOperator.new(path).del_git_module(module_name) end |
#pull(path, user, module_name, home_branch_name, type) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/big_keeper/service/module_service.rb', line 59 def pull(path, user, module_name, home_branch_name, type) Logger.highlight("Pull branch '#{home_branch_name}' for module '#{module_name}'...") verify_module(path, user, module_name, home_branch_name, type) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) GitOperator.new.pull(module_full_path) end |
#push(path, user, module_name, home_branch_name, type, comment) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/big_keeper/service/module_service.rb', line 34 def push(path, user, module_name, home_branch_name, type, comment) Logger.highlight("Push branch '#{home_branch_name}' for module '#{module_name}'...") verify_module(path, user, module_name, home_branch_name, type) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) GitService.new.verify_push(module_full_path, comment, home_branch_name, module_name) end |
#rebase(path, user, module_name, home_branch_name, type) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/big_keeper/service/module_service.rb', line 43 def rebase(path, user, module_name, home_branch_name, type) Logger.highlight("Rebase '#{GitflowType.base_branch(type)}' "\ "to branch '#{home_branch_name}' for module "\ "'#{module_name}'...") verify_module(path, user, module_name, home_branch_name, type) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) Logger.error("You have some changes in branch "\ "'#{home_branch_name}' for module '#{module_name}'. "\ "Use 'push' first please") if GitOperator.new.has_changes(module_full_path) GitService.new.verify_rebase(module_full_path, GitflowType.base_branch(type), module_name) end |
#switch_to(path, user, module_name, home_branch_name, type) ⇒ Object
68 69 70 71 72 |
# File 'lib/big_keeper/service/module_service.rb', line 68 def switch_to(path, user, module_name, home_branch_name, type) Logger.highlight("Switch to branch '#{home_branch_name}' for module '#{module_name}'...") verify_module(path, user, module_name, home_branch_name, type) end |