222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
# File 'lib/m-git/command/pull.rb', line 222
def pull_config_repo(cmd, opts, repo)
if !repo.nil?
branch_status = repo.status_checker.branch_status
if branch_status == Repo::Status::GIT_BRANCH_STATUS[:detached]
remind_config_repo_fail("主仓库\"#{repo.name}\"HEAD游离,当前不在任何分支上,无法执行!")
elsif branch_status == Repo::Status::GIT_BRANCH_STATUS[:no_tracking]
remind_config_repo_fail("主仓库\"#{repo.name}\"未跟踪对应远程分支,无法执行!(需要执行'mgit branch -u origin/<branch>')")
elsif branch_status == Repo::Status::GIT_BRANCH_STATUS[:no_remote]
remind_config_repo_fail("主仓库\"#{repo.name}\"远程分支不存在,无法执行!")
else
Output.puts_processing_message("开始操作主仓库...")
exec_subrepos = all_repos(except_config:true)
is_all = Workspace.is_all_exec_sub_repos?(exec_subrepos)
context = OperationProgressContext.new(__progress_type)
context.cmd = cmd
context.opts = opts
context.repos = is_all ? nil : exec_subrepos.map { |e| e.name } context.branch = repo.status_checker.current_branch(use_cache:true)
if opts.length == 0
branch = repo.status_checker.current_branch(strict_mode:false, use_cache:true)
tracking_branch = repo.status_checker.tracking_branch(branch, use_cache:true)
msg = "-m \"【Merge】【0.0.0】【#{branch}】合并远程分支'#{tracking_branch}'。\"" if branch_status == Repo::Status::GIT_BRANCH_STATUS[:diverged]
cmd, opts = "merge", "#{tracking_branch} #{msg}"
end
success, output = repo.execute_git_cmd(cmd, opts)
if success
Output.puts_success_message("主仓库操作成功!\n")
else
Output.puts_fail_message("主仓库操作失败!\n")
config_error = output
end
begin
Workspace.update_config(strict_mode:false) { |missing_repos|
if missing_repos.length > 0
success_missing_repos = Workspace.guide_to_checkout_branch(missing_repos, all_repos, append_message:"拒绝该操作本次执行将忽略以上仓库")
all_repos.concat(success_missing_repos)
all_repos.uniq! { |repo| repo.name }
end
}
refresh_context(context)
rescue Error => e
if e.type == MGIT_ERROR_TYPE[:config_generate_error]
OperationProgressManager.trap_into_progress(Workspace.root, context)
show_progress_error("配置表生成失败", "#{e.msg}")
end
end
return config_error
end
end
end
|