Method: MGit::Workspace.update_config
- Defined in:
- lib/m-git/workspace.rb
.update_config(strict_mode: true) {|missing_repos| ... } ⇒ Object
更新配置解析结果,并同步缺失仓库
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/m-git/workspace.rb', line 93 def update_config(strict_mode:true) Output.("检查多仓库配置信息...") if setup_config(strict_mode:strict_mode) Output.("配置信息已更新!\n") else # 配置表未更新,直接返回 Output.("配置信息已为最新!\n") return end origin_all_repo_names = all_repos.map { |e| e.name } @all_repos, @exec_light_repos = nil, nil missing_repos = [] missing_light_repos = setup_all_repos(strict_mode:false) if missing_light_repos.length > 0 Utils.show_clone_info(root, missing_light_repos) mutex = Mutex.new error_repos = {} task_count = 0 Output.update_progress(missing_light_repos.length, task_count) concurrent_enumerate(missing_light_repos) { |light_repo| , _ = Repo::SyncHelper.sync_new_repo(light_repo, root) mutex.lock if .nil? missing_repos.push(Repo.generate_strictly(root, light_repo)) else error_repos[light_repo.name] = end task_count += 1 Output.update_progress(missing_light_repos.length, task_count) mutex.unlock } if error_repos.length > 0 show_error(error_repos, action:'下载操作') #(注意,如果不希望被下载仓库的.git实体被mgit管理,请执行\"mgit sync -n -o\",该方式将不会把.git实体放置到.mgit/souce-git中,更适合开发中途接入mgit的用户) Foundation.help!("请检查原因并执行\"mgit sync -n\"重新下载。") else Output.("下载成功!\n") end end # 加入将当前分支上本地已有的新仓库 current_branch_exist_new_repos = all_repos.select { |repo| !origin_all_repo_names.include?(repo.name) } missing_repos += current_branch_exist_new_repos # 新仓库当前分支可能并不是所需分支,可以再进一步操作 yield(missing_repos) if block_given? && missing_repos.length > 0 end |