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
- #release_check_changed(path, user, module_name) ⇒ Object
- #release_finish(path, user, modules, module_name, version) ⇒ Object
- #release_start(path, user, modules, module_name, version) ⇒ Object
- #switch_to(path, user, module_name, home_branch_name, type) ⇒ Object
Instance Method Details
#add(path, user, module_name, name, type) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/big_keeper/service/module_service.rb', line 109 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
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/big_keeper/service/module_service.rb', line 123 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
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/big_keeper/service/module_service.rb', line 95 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
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/big_keeper/service/module_service.rb', line 140 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
72 73 74 75 76 77 78 79 80 |
# File 'lib/big_keeper/service/module_service.rb', line 72 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
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/big_keeper/service/module_service.rb', line 82 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
57 58 59 60 61 62 63 64 |
# File 'lib/big_keeper/service/module_service.rb', line 57 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
32 33 34 35 36 37 38 39 |
# File 'lib/big_keeper/service/module_service.rb', line 32 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
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/big_keeper/service/module_service.rb', line 41 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 |
#release_check_changed(path, user, module_name) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/big_keeper/service/module_service.rb', line 157 def release_check_changed(path, user, module_name) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) git = GitOperator.new if !File.exist? module_full_path Logger.default("No local repository for module '#{module_name}', clone it...") module_git = BigkeeperParser.module_git(module_name) git.clone(File.("#{module_full_path}/../"), module_git) end GitService.new.verify_checkout_pull(module_full_path, 'develop') git.check_remote_branch_diff(module_full_path, 'develop', 'master') end |
#release_finish(path, user, modules, module_name, version) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/big_keeper/service/module_service.rb', line 196 def release_finish(path, user, modules, module_name, version) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) git = GitOperator.new if !File.exist? module_full_path Logger.default("No local repository for module '#{module_name}', clone it...") module_git = BigkeeperParser.module_git(module_name) git.clone(File.("#{module_full_path}/../"), module_git) end #stash module StashService.new.stash(module_full_path, GitOperator.new.current_branch(module_full_path), module_name) # delete cache CacheOperator.new(module_full_path).clean() # checkout develop GitService.new.verify_checkout_pull(module_full_path, 'develop') DepService.dep_operator(path, user).release_module_finish(modules, module_name, version) # Push home changes to remote Logger.highlight("Push branch 'develop' for #{module_name}...") GitService.new.verify_push( module_full_path, "release finish for #{version}", 'develop', "#{module_name}") end |
#release_start(path, user, modules, module_name, version) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/big_keeper/service/module_service.rb', line 170 def release_start(path, user, modules, module_name, version) module_full_path = BigkeeperParser.module_full_path(path, user, module_name) git = GitOperator.new if !File.exist? module_full_path Logger.default("No local repository for module '#{module_name}', clone it...") module_git = BigkeeperParser.module_git(module_name) git.clone(File.("#{module_full_path}/../"), module_git) end #stash module StashService.new.stash(module_full_path, GitOperator.new.current_branch(module_full_path), module_name) # delete cache CacheOperator.new(module_full_path).clean() # checkout develop GitService.new.verify_checkout_pull(module_full_path, 'develop') DepService.dep_operator(path, user).release_module_start(modules, module_name, version) # Push home changes to remote Logger.highlight("Push branch 'develop' for #{module_name}...") GitService.new.verify_push( module_full_path, "release start for #{version}", 'develop', "#{module_name}") end |
#switch_to(path, user, module_name, home_branch_name, type) ⇒ Object
66 67 68 69 70 |
# File 'lib/big_keeper/service/module_service.rb', line 66 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 |