m-git 2.5.4 → 2.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/m-git/command/config.rb +2 -2
- data/lib/m-git/command/init.rb +1 -1
- data/lib/m-git/command/push.rb +2 -2
- data/lib/m-git/foundation/constants.rb +2 -1
- data/lib/m-git/foundation/mgit_config.rb +1 -1
- data/lib/m-git/hooks_manager.rb +1 -1
- data/lib/m-git/manifest/light_repo.rb +3 -0
- data/lib/m-git/manifest/light_repo_generator.rb +2 -1
- data/lib/m-git/manifest/linter.rb +1 -1
- data/lib/m-git/plugin_manager.rb +4 -3
- data/lib/m-git/repo/sync_helper.rb +41 -0
- data/lib/m-git/version.rb +1 -1
- data/m-git +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77220cb1407e06eff83ee8f4fe617c34355301b5928ce67d4c82c0ae23402d4c
|
4
|
+
data.tar.gz: 93a2f2eafc405eab27aaf420967e7a791c6e62baeba93e6c35efc847822d5b57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0d257a7e6844cffbae5af66ed7584b7c828236555967101188eaf283e0591498a6c8494cefa2d5a492bef9692d6f51dd4450e28cc0c549e026af8cbeb7604e4
|
7
|
+
data.tar.gz: ead3235aae1f1f720da6ae6466107393f74e7668990fcc649aa8f8157e81a04af6610a112fdb204b213f86d596293864f2f04193d9d3ab0457335271f5c25c7d
|
data/lib/m-git/command/config.rb
CHANGED
@@ -26,11 +26,11 @@ module MGit
|
|
26
26
|
ARGV::Opt.new(OPT_LIST[:update_manifest],
|
27
27
|
short_key:OPT_LIST[:update_manifest_s],
|
28
28
|
info:"该指令用于更新mgit所使用的配置文件,如:\"mgit config -m <new_path>/manifest.json\"。",
|
29
|
-
type: :
|
29
|
+
type: :string),
|
30
30
|
ARGV::Opt.new(OPT_LIST[:update_local],
|
31
31
|
short_key:OPT_LIST[:update_local_s],
|
32
32
|
info:"该指令用于更新mgit所使用的本地配置文件,如:\"mgit config -u <new_path>/local_manifest.json\"。",
|
33
|
-
type: :
|
33
|
+
type: :string),
|
34
34
|
ARGV::Opt.new(OPT_LIST[:create_local],
|
35
35
|
short_key:OPT_LIST[:create_local_s],
|
36
36
|
info:"在指定目录下创建本地配置文件,若目录不存在则自动创建。如执行:\"mgit config -c /a/b/c\",则生成本地配置文件:\"/a/b/c/local_manifest.json\"。如果未传入值,如:\"mgit config -c\",那么若配置仓库存在的话,会在配置仓库中创建本地配置文件。",
|
data/lib/m-git/command/init.rb
CHANGED
@@ -297,7 +297,7 @@ module MGit
|
|
297
297
|
def move_project_to_root
|
298
298
|
Dir.foreach(Workspace.root) { |item|
|
299
299
|
if item != '.' && item != '..' && item != '.DS_Store'
|
300
|
-
FileUtils.mv(File.join(Workspace.root, item), @origin_root)
|
300
|
+
FileUtils.mv(File.join(Workspace.root, item), @origin_root, force: true)
|
301
301
|
end
|
302
302
|
}
|
303
303
|
FileUtils.remove_dir(Workspace.root, true) if Dir.exist?(Workspace.root)
|
data/lib/m-git/command/push.rb
CHANGED
@@ -23,10 +23,10 @@ module MGit
|
|
23
23
|
def options
|
24
24
|
[
|
25
25
|
ARGV::Opt.new(OPT_LIST[:gerrit],
|
26
|
-
info:"开启gerrit功能,如果没有对应远程分支则推送新分支,否则推送到审查分支(refs/for
|
26
|
+
info:"开启gerrit功能,如果没有对应远程分支则推送新分支,否则推送到审查分支(refs/for/**),默认#{MGIT_PUSH_GERRIT_ENABLED ? '已开启' : '未开启' }",
|
27
27
|
type: :boolean),
|
28
28
|
ARGV::Opt.new(OPT_LIST[:topic_id],
|
29
|
-
info:"指定一组变更的分类topic
|
29
|
+
info:"指定一组变更的分类topic,若未指定则自动生成,默认#{MGIT_PUSH_TOPIC_ENABLED ? '已开启' : '未开启'},开启后强制开启Gerrit功能。mgit push --topic 12345 = git push origin HEAD:refs/for/<branch>%topic=12345",
|
30
30
|
type: :string),
|
31
31
|
].concat(super)
|
32
32
|
end
|
data/lib/m-git/hooks_manager.rb
CHANGED
@@ -83,7 +83,7 @@ module MGit
|
|
83
83
|
# block
|
84
84
|
def __execute_hook_file(file_name, hook_class)
|
85
85
|
file_path = File.join(Workspace.hooks_dir, file_name)
|
86
|
-
if File.
|
86
|
+
if File.exist?(file_path)
|
87
87
|
require file_path
|
88
88
|
end
|
89
89
|
if Object.const_defined?(hook_class) && hook = Object.const_get(hook_class)
|
@@ -16,7 +16,7 @@ module MGit
|
|
16
16
|
# @return [LightRepo] 配置对象
|
17
17
|
#
|
18
18
|
def self.simple_init(name, path, url)
|
19
|
-
LightRepo.new(name, path, nil, nil, nil, url, false, false, false, false)
|
19
|
+
LightRepo.new(name, path, nil, nil, nil, nil, url, false, false, false, false)
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.light_repo_with(name, config_json, parent_json)
|
@@ -30,6 +30,7 @@ module MGit
|
|
30
30
|
light_repo.commit_id = lock_info[Constants::REPO_CONFIG_LOCK_KEY[:commit_id]]
|
31
31
|
light_repo.tag = lock_info[Constants::REPO_CONFIG_LOCK_KEY[:tag]]
|
32
32
|
light_repo.branch = lock_info[Constants::REPO_CONFIG_LOCK_KEY[:branch]]
|
33
|
+
light_repo.change_ref = lock_info[Constants::REPO_CONFIG_LOCK_KEY[:change_ref]]
|
33
34
|
end
|
34
35
|
light_repo.url = __parse_url(config_json, parent_json)
|
35
36
|
|
@@ -12,7 +12,7 @@ module MGit
|
|
12
12
|
def lint_manifest_path(path)
|
13
13
|
manifest_name = Constants::CONFIG_FILE_NAME[:manifest]
|
14
14
|
|
15
|
-
if !File.
|
15
|
+
if !File.exist?(path)
|
16
16
|
if File.symlink?(path)
|
17
17
|
terminate!("配置文件软链接#{path}失效,请执行\"mgit config -m <new_path>/manifest.json\"更新!")
|
18
18
|
else
|
data/lib/m-git/plugin_manager.rb
CHANGED
@@ -59,7 +59,7 @@ module MGit
|
|
59
59
|
with_name ||= plugin_root
|
60
60
|
glob = "#{plugin_prefix}_plugin#{Gem.suffix_pattern}"
|
61
61
|
glob = File.join(plugin_root, '**', glob)
|
62
|
-
plugin_files = Dir[glob]
|
62
|
+
plugin_files = Dir[glob]
|
63
63
|
return if loaded_plugins[with_name] || plugin_files.nil? || plugin_files.empty?
|
64
64
|
safe_activate_plugin_files(with_name, plugin_files)
|
65
65
|
loaded_plugins[with_name] = plugin_files
|
@@ -70,6 +70,7 @@ module MGit
|
|
70
70
|
def self.load_gem_plugins(plugin_prefix)
|
71
71
|
glob = "#{plugin_prefix}_plugin#{Gem.suffix_pattern}"
|
72
72
|
gem_plugins = Gem::Specification.latest_specs.map do |spec|
|
73
|
+
spec = spec.to_spec unless spec.is_a?(Gem::Specification)
|
73
74
|
matches = spec.matches_for_glob(glob)
|
74
75
|
[spec, matches] unless matches.empty?
|
75
76
|
end.compact
|
@@ -91,7 +92,7 @@ module MGit
|
|
91
92
|
message << "\n#{exception.class} - #{exception.message}"
|
92
93
|
message << "\n#{exception.backtrace.join("\n")}"
|
93
94
|
message << "\n---------------------------------------------\n"
|
94
|
-
warn message
|
95
|
+
warn message
|
95
96
|
false
|
96
97
|
end
|
97
98
|
|
@@ -104,7 +105,7 @@ module MGit
|
|
104
105
|
message << "\n#{exception.class} - #{exception.message}"
|
105
106
|
message << "\n#{exception.backtrace.join("\n")}"
|
106
107
|
message << "\n---------------------------------------------\n"
|
107
|
-
warn message
|
108
|
+
warn message
|
108
109
|
false
|
109
110
|
end
|
110
111
|
|
@@ -134,6 +134,8 @@ module MGit
|
|
134
134
|
return sync_tag(repo, light_repo)
|
135
135
|
elsif !light_repo.branch.nil?
|
136
136
|
return sync_branch(repo, light_repo)
|
137
|
+
elsif !light_repo.change_ref.nil?
|
138
|
+
return sync_change_ref(repo, light_repo)
|
137
139
|
end
|
138
140
|
end
|
139
141
|
|
@@ -210,6 +212,45 @@ module MGit
|
|
210
212
|
|
211
213
|
end
|
212
214
|
|
215
|
+
# 同步 change ref
|
216
|
+
#
|
217
|
+
# @param repo [Repo] Repo对象
|
218
|
+
#
|
219
|
+
# @param light_repo [Manifest::LightRepo] LightRepo对象
|
220
|
+
#
|
221
|
+
# @return [Boolean] 执行结果,成功返回nil,错误返回错误信息
|
222
|
+
#
|
223
|
+
def sync_change_ref(repo, light_repo)
|
224
|
+
current_branch = repo.status_checker.current_branch(strict_mode:false)
|
225
|
+
local_branch_exist = repo.status_checker.local_branch_exist?(light_repo.branch)
|
226
|
+
remote_branch_exist = repo.status_checker.remote_branch_exist?(light_repo.branch)
|
227
|
+
is_dirty = repo.status_checker.status == Status::GIT_REPO_STATUS[:dirty]
|
228
|
+
|
229
|
+
# 当前已在目标切换分支则不操作
|
230
|
+
if current_branch == light_repo.branch
|
231
|
+
return nil
|
232
|
+
# 本地或远程存在目标分支则切换
|
233
|
+
# elsif local_branch_exist || remote_branch_exist || Utils.branch_exist_on_remote?(light_repo.branch, light_repo.url)
|
234
|
+
|
235
|
+
else
|
236
|
+
# return "仓库change_ref \"#{light_repo.change_ref}\"不存在,请检查是否拼写错误!"
|
237
|
+
# 本地无目标分支则先拉取
|
238
|
+
if !local_branch_exist && !remote_branch_exist
|
239
|
+
success, error = repo.execute_git_cmd('fetch origin', light_repo.change_ref)
|
240
|
+
puts error
|
241
|
+
return error if !success
|
242
|
+
end
|
243
|
+
|
244
|
+
if !is_dirty
|
245
|
+
success, output = repo.execute_git_cmd('checkout', 'FETCH_HEAD')
|
246
|
+
puts output
|
247
|
+
return output if !success
|
248
|
+
else
|
249
|
+
return "本地有改动, 无法切换到\"#{light_repo.change_ref}\", 请处理后重试!"
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
213
254
|
# 同步remote url
|
214
255
|
#
|
215
256
|
# @param repo [Repo] Repo对象
|
data/lib/m-git/version.rb
CHANGED
data/m-git
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
mgit
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: m-git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhangyu81
|
8
8
|
autorequire:
|
9
9
|
bindir: "./"
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored2
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: logger
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.4.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.4.2
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
225
|
- !ruby/object:Gem::Version
|
212
226
|
version: '0'
|
213
227
|
requirements: []
|
214
|
-
rubygems_version: 3.
|
228
|
+
rubygems_version: 3.4.13
|
215
229
|
signing_key:
|
216
230
|
specification_version: 4
|
217
231
|
summary: A multi-repository management tool integrated with git.
|