kookeeper 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/.gitignore +8 -0
- data/.idea/bigkeeper.iml +68 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/CONTRIBUTING.md +70 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +145 -0
- data/LICENSE +21 -0
- data/README.md +113 -0
- data/big_keeper.gemspec +50 -0
- data/docs/en-US/FEATURE.md +0 -0
- data/docs/en-US/README.md +54 -0
- data/docs/zh-CN/BIGKEEPER_FILE.md +84 -0
- data/docs/zh-CN/FEATURE&HOTFIX.md +88 -0
- data/docs/zh-CN/IMAGE.md +0 -0
- data/docs/zh-CN/PODFILE.md +43 -0
- data/docs/zh-CN/README.md +113 -0
- data/docs/zh-CN/RECOMMEND.md +22 -0
- data/docs/zh-CN/RELEASE.md +60 -0
- data/docs/zh-CN/SPEC.md +39 -0
- data/lib/big_keeper/command/feature&hotfix/delete.rb +40 -0
- data/lib/big_keeper/command/feature&hotfix/finish.rb +54 -0
- data/lib/big_keeper/command/feature&hotfix/list.rb +63 -0
- data/lib/big_keeper/command/feature&hotfix/publish.rb +56 -0
- data/lib/big_keeper/command/feature&hotfix/pull.rb +26 -0
- data/lib/big_keeper/command/feature&hotfix/push.rb +27 -0
- data/lib/big_keeper/command/feature&hotfix/rebase.rb +32 -0
- data/lib/big_keeper/command/feature&hotfix/start.rb +74 -0
- data/lib/big_keeper/command/feature&hotfix/switch.rb +46 -0
- data/lib/big_keeper/command/feature&hotfix/update.rb +66 -0
- data/lib/big_keeper/command/feature&hotfix.rb +167 -0
- data/lib/big_keeper/command/image/image.rb +0 -0
- data/lib/big_keeper/command/image.rb +28 -0
- data/lib/big_keeper/command/pod/podfile.rb +69 -0
- data/lib/big_keeper/command/pod.rb +42 -0
- data/lib/big_keeper/command/release/home.rb +91 -0
- data/lib/big_keeper/command/release/module.rb +61 -0
- data/lib/big_keeper/command/release.rb +75 -0
- data/lib/big_keeper/command/spec/add.rb +9 -0
- data/lib/big_keeper/command/spec/analyze.rb +88 -0
- data/lib/big_keeper/command/spec/delete.rb +9 -0
- data/lib/big_keeper/command/spec/list.rb +19 -0
- data/lib/big_keeper/command/spec/search.rb +9 -0
- data/lib/big_keeper/command/spec/sync.rb +12 -0
- data/lib/big_keeper/command/spec.rb +78 -0
- data/lib/big_keeper/dependency/dep_gradle_operator.rb +56 -0
- data/lib/big_keeper/dependency/dep_operator.rb +32 -0
- data/lib/big_keeper/dependency/dep_pod_operator.rb +130 -0
- data/lib/big_keeper/dependency/dep_service.rb +14 -0
- data/lib/big_keeper/dependency/dep_type.rb +33 -0
- data/lib/big_keeper/model/gitflow_type.rb +43 -0
- data/lib/big_keeper/model/library_model.rb +116 -0
- data/lib/big_keeper/model/operate_type.rb +27 -0
- data/lib/big_keeper/model/podfile_model.rb +33 -0
- data/lib/big_keeper/service/git_service.rb +210 -0
- data/lib/big_keeper/service/module_service.rb +159 -0
- data/lib/big_keeper/service/stash_service.rb +45 -0
- data/lib/big_keeper/util/bigkeeper_parser.rb +244 -0
- data/lib/big_keeper/util/cache_operator.rb +116 -0
- data/lib/big_keeper/util/code_operator.rb +37 -0
- data/lib/big_keeper/util/file_operator.rb +33 -0
- data/lib/big_keeper/util/git_operator.rb +221 -0
- data/lib/big_keeper/util/gitflow_operator.rb +51 -0
- data/lib/big_keeper/util/gradle_operator.rb +209 -0
- data/lib/big_keeper/util/info_plist_operator.rb +46 -0
- data/lib/big_keeper/util/leancloud_logger.rb +72 -0
- data/lib/big_keeper/util/list_generator.rb +101 -0
- data/lib/big_keeper/util/logger.rb +46 -0
- data/lib/big_keeper/util/pod_operator.rb +70 -0
- data/lib/big_keeper/util/podfile_detector.rb +111 -0
- data/lib/big_keeper/util/podfile_module.rb +63 -0
- data/lib/big_keeper/util/podfile_operator.rb +117 -0
- data/lib/big_keeper/util/verify_operator.rb +17 -0
- data/lib/big_keeper/util/xcode_operator.rb +15 -0
- data/lib/big_keeper/version.rb +3 -0
- data/lib/big_keeper.rb +71 -0
- data/resources/banner.png +0 -0
- data/resources/command.png +0 -0
- data/resources/keynote/big-keeper-readme-analyze.key +0 -0
- data/resources/keynote/big-keeper-readme-example.key +0 -0
- data/resources/keynote/big-keeper-readme-feature.key +0 -0
- data/resources/keynote/big-keeper-readme-release.key +0 -0
- data/resources/readme/big-keeper-readme.001.png +0 -0
- metadata +85 -2
@@ -0,0 +1,209 @@
|
|
1
|
+
require 'big_keeper/util/cache_operator'
|
2
|
+
|
3
|
+
module BigKeeper
|
4
|
+
# Operator for podfile
|
5
|
+
class GradleOperator
|
6
|
+
def initialize(path)
|
7
|
+
@path = path
|
8
|
+
end
|
9
|
+
|
10
|
+
def backup
|
11
|
+
cache_operator = CacheOperator.new(@path)
|
12
|
+
|
13
|
+
cache_operator.save('settings.gradle')
|
14
|
+
|
15
|
+
Dir.glob("#{@path}/*/build.gradle").each do |build_gradle_file_path|
|
16
|
+
build_gradle_file = build_gradle_file_path.gsub!(/#{@path}/, '')
|
17
|
+
cache_operator.save(build_gradle_file)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def recover(settings_config, build_config)
|
22
|
+
cache_operator = CacheOperator.new(@path)
|
23
|
+
|
24
|
+
cache_operator.load('settings.gradle') if settings_config
|
25
|
+
|
26
|
+
if build_config
|
27
|
+
Dir.glob("#{@path}/*/build.gradle").each do |build_gradle_file_path|
|
28
|
+
build_gradle_file = build_gradle_file_path.gsub!(/#{@path}/, '')
|
29
|
+
cache_operator.load(build_gradle_file)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
cache_operator.clean
|
34
|
+
end
|
35
|
+
|
36
|
+
def update_settings_config(current_module_name, modules, module_operate_type, user)
|
37
|
+
return if modules.empty?
|
38
|
+
|
39
|
+
if ModuleOperateType::ADD == module_operate_type
|
40
|
+
modules.each do |module_name|
|
41
|
+
next if current_module_name == module_name
|
42
|
+
|
43
|
+
File.open("#{@path}/settings.gradle", 'a') do |file|
|
44
|
+
file.puts "\r\ninclude ':module:#{module_name.downcase}'\r\n"
|
45
|
+
file.puts "project(':module:#{module_name.downcase}')." \
|
46
|
+
"projectDir = new File(rootProject.projectDir," \
|
47
|
+
"'#{BigkeeperParser.module_path(user, module_name)}/#{module_name.downcase}-lib')\r\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
else
|
51
|
+
modules.each do |module_name|
|
52
|
+
next if current_module_name == module_name
|
53
|
+
temp_file = Tempfile.new('.settings.gradle.tmp')
|
54
|
+
begin
|
55
|
+
File.open("#{@path}/settings.gradle", 'r') do |file|
|
56
|
+
file.each_line do |line|
|
57
|
+
unless line =~ /(\s*)include(\s*)('|")(\S*):#{module_name.downcase}('|")(\S*)/ ||
|
58
|
+
line =~ /(\s*)project\(('|")(\S*):#{module_name.downcase}('|")\).(\S*)/
|
59
|
+
temp_file.puts(line)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
temp_file.close
|
64
|
+
FileUtils.mv(temp_file.path, "#{@path}/settings.gradle")
|
65
|
+
ensure
|
66
|
+
temp_file.close
|
67
|
+
temp_file.unlink
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def update_build_config(current_module_name, modules, module_operate_type)
|
74
|
+
return if modules.empty?
|
75
|
+
|
76
|
+
Dir.glob("#{@path}/*/build.gradle").each do |file_path|
|
77
|
+
modules.each do |module_name|
|
78
|
+
next if current_module_name == module_name
|
79
|
+
|
80
|
+
temp_file = Tempfile.new('.build.gradle.tmp')
|
81
|
+
begin
|
82
|
+
version_flag = false
|
83
|
+
version_index = 0
|
84
|
+
|
85
|
+
File.open(file_path, 'r') do |file|
|
86
|
+
file.each_line do |line|
|
87
|
+
new_line, version_index, version_flag = generate_build_config(
|
88
|
+
line,
|
89
|
+
module_name,
|
90
|
+
module_operate_type,
|
91
|
+
version_index,
|
92
|
+
version_flag)
|
93
|
+
|
94
|
+
temp_file.puts(new_line)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
temp_file.close
|
98
|
+
FileUtils.mv(temp_file.path, file_path)
|
99
|
+
ensure
|
100
|
+
temp_file.close
|
101
|
+
temp_file.unlink
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def generate_build_config(line, module_name, module_operate_type, version_index, version_flag)
|
108
|
+
new_line = line
|
109
|
+
|
110
|
+
version_flag = true if line.downcase.include? 'modifypom'
|
111
|
+
if version_flag
|
112
|
+
version_index += 1 if line.include? '{'
|
113
|
+
version_index -= 1 if line.include? '}'
|
114
|
+
|
115
|
+
version_flag = false if 0 == version_flag
|
116
|
+
|
117
|
+
new_line = generate_version_config(line, module_name, module_operate_type)
|
118
|
+
else
|
119
|
+
new_line = generate_compile_config(line, module_name, module_operate_type)
|
120
|
+
end
|
121
|
+
|
122
|
+
[new_line, version_index, version_flag]
|
123
|
+
end
|
124
|
+
|
125
|
+
def generate_version_config(line, module_name, module_operate_type)
|
126
|
+
if ModuleOperateType::FINISH == module_operate_type || ModuleOperateType::PUBLISH == module_operate_type
|
127
|
+
branch_name = GitOperator.new.current_branch(@path)
|
128
|
+
full_name = ''
|
129
|
+
|
130
|
+
# Get version part of source.addition
|
131
|
+
if ModuleOperateType::PUBLISH == module_operate_type
|
132
|
+
full_name = branch_name.sub(/([\s\S]*)\/(\d+.\d+.\d+)_([\s\S]*)/){ $2 }
|
133
|
+
else
|
134
|
+
full_name = branch_name.sub(/([\s\S]*)\/([\s\S]*)/){ $2 }
|
135
|
+
end
|
136
|
+
|
137
|
+
line.sub(/(\s*)version ('|")(\S*)('|")([\s\S]*)/){
|
138
|
+
"#{$1}version '#{full_name}'#{$5}"
|
139
|
+
}
|
140
|
+
else
|
141
|
+
line
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def generate_compile_config(line, module_name, module_operate_type)
|
146
|
+
if ModuleOperateType::ADD == module_operate_type
|
147
|
+
line.sub(/(\s*)compile(\s*)('|")(\S*):#{module_name.downcase}:(\S*)('|")(\S*)/){
|
148
|
+
"#{$1}compile project(':module:#{module_name.downcase}')"
|
149
|
+
}
|
150
|
+
elsif ModuleOperateType::DELETE == module_operate_type
|
151
|
+
line.sub(/(\s*)([\s\S]*)('|")(\S*):#{module_name.downcase}:(\S*)('|")(\S*)/){
|
152
|
+
origin_config_of_module = origin_config_of_module(module_name)
|
153
|
+
if origin_config_of_module.empty?
|
154
|
+
line
|
155
|
+
else
|
156
|
+
origin_config_of_module
|
157
|
+
end
|
158
|
+
}
|
159
|
+
elsif ModuleOperateType::FINISH == module_operate_type || ModuleOperateType::PUBLISH == module_operate_type
|
160
|
+
branch_name = GitOperator.new.current_branch(@path)
|
161
|
+
full_name = ''
|
162
|
+
|
163
|
+
# Get version part of source.addition
|
164
|
+
if ModuleOperateType::PUBLISH == module_operate_type
|
165
|
+
full_name = branch_name.sub(/([\s\S]*)\/(\d+.\d+.\d+)_([\s\S]*)/){ $2 }
|
166
|
+
else
|
167
|
+
full_name = branch_name.sub(/([\s\S]*)\/([\s\S]*)/){ $2 }
|
168
|
+
end
|
169
|
+
line.sub(/(\s*)([\s\S]*)('|")(\S*):#{module_name.downcase}(:\S*)*('|")(\S*)/){
|
170
|
+
if $2.downcase.include? 'modulecompile'
|
171
|
+
"#{$1}moduleCompile '#{prefix_of_module(module_name)}:#{module_name.downcase}:#{full_name}-SNAPSHOT'"
|
172
|
+
else
|
173
|
+
"#{$1}compile '#{prefix_of_module(module_name)}:#{module_name.downcase}:#{full_name}-SNAPSHOT'"
|
174
|
+
end
|
175
|
+
}
|
176
|
+
else
|
177
|
+
line
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def origin_config_of_module(module_name)
|
182
|
+
origin_config = ''
|
183
|
+
|
184
|
+
Dir.glob("#{@path}/.bigkeeper/*/build.gradle").each do |file|
|
185
|
+
File.open(file, 'r') do |file|
|
186
|
+
file.each_line do |line|
|
187
|
+
if line =~ /(\s*)([\s\S]*)('|")(\S*):#{module_name.downcase}:(\S*)('|")(\S*)/
|
188
|
+
origin_config = line
|
189
|
+
break
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
break unless origin_config.empty?
|
194
|
+
end
|
195
|
+
|
196
|
+
origin_config.chop
|
197
|
+
end
|
198
|
+
|
199
|
+
def prefix_of_module(module_name)
|
200
|
+
origin_config = origin_config_of_module(module_name)
|
201
|
+
prefix = origin_config.sub(/(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
|
202
|
+
$4
|
203
|
+
}
|
204
|
+
prefix.chop
|
205
|
+
end
|
206
|
+
|
207
|
+
private :generate_build_config, :generate_compile_config, :generate_version_config, :origin_config_of_module, :prefix_of_module
|
208
|
+
end
|
209
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'plist' # gem install plist
|
3
|
+
require 'big_stash/stash_operator'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
module BigKeeper
|
7
|
+
# Operator for Info.plist
|
8
|
+
class InfoPlistOperator
|
9
|
+
def change_version_build(path, version)
|
10
|
+
if find_infoPlist_filePath(path) == ''
|
11
|
+
raise %(Not find be Info.plist at #{path})
|
12
|
+
end
|
13
|
+
info_plist_path = find_infoPlist_filePath(path)
|
14
|
+
result = Plist.parse_xml(info_plist_path)
|
15
|
+
result['CFBundleVersion'] = getBuildVersion(version, result['CFBundleShortVersionString'], result['CFBundleVersion']).to_s
|
16
|
+
result['CFBundleShortVersionString'] = version.to_s
|
17
|
+
Plist::Emit.save_plist(result, info_plist_path)
|
18
|
+
puts %Q('Version has changed to #{version}')
|
19
|
+
end
|
20
|
+
|
21
|
+
# Find Info.plist file path
|
22
|
+
# @return [String] pathName of info.plist
|
23
|
+
def find_infoPlist_filePath(path)
|
24
|
+
paths = Pathname.new(path).children.select { |pn| pn.extname == '.xcodeproj' }
|
25
|
+
xcodePath = paths[0].to_s.split('/')[-1]
|
26
|
+
projectName = xcodePath.split('.')[0]
|
27
|
+
projectPath = ''
|
28
|
+
Pathname.new("#{path}/#{projectName}").children.select { |pn|
|
29
|
+
if pn.to_s == "#{path}/#{projectName}/Info.plist"
|
30
|
+
projectPath = "#{path}/#{projectName}/Info.plist"
|
31
|
+
end
|
32
|
+
}
|
33
|
+
projectPath
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def getBuildVersion(build_string, old_build_string, old_build_version)
|
38
|
+
if build_string == old_build_string
|
39
|
+
return old_build_version.to_i + 1
|
40
|
+
else
|
41
|
+
version_arr = build_string.split('.')
|
42
|
+
return version_arr[0].to_i * 1000 + version_arr[1].to_i * 100 + version_arr[2].to_i * 10
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'Singleton'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
require 'big_keeper/util/logger'
|
5
|
+
|
6
|
+
module BigKeeper
|
7
|
+
class LeanCloudLogger
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
attr_accessor :user, :version, :start_timestamp, :end_timestamp, :command, :parameter, :is_success, :path
|
11
|
+
|
12
|
+
def set_command(set_command)
|
13
|
+
@command = set_command
|
14
|
+
end
|
15
|
+
|
16
|
+
def start_log(global_options, args)
|
17
|
+
@start_timestamp = Time.new.to_i
|
18
|
+
@user = global_options['user'].to_s
|
19
|
+
@parameter = args.join(",")
|
20
|
+
@version = global_options['ver']
|
21
|
+
@path = global_options['path']
|
22
|
+
end
|
23
|
+
|
24
|
+
def end_log(is_success)
|
25
|
+
@end_timestamp = Time.new.to_i
|
26
|
+
@is_success = is_success
|
27
|
+
@version = BigkeeperParser.version if @version == 'Version in Bigkeeper file'
|
28
|
+
|
29
|
+
# require
|
30
|
+
parameter = {'start_timestamp' => @start_timestamp, 'end_timestamp' =>@end_timestamp, 'user' =>@user, 'is_success' =>@is_success}
|
31
|
+
|
32
|
+
# optional
|
33
|
+
parameter = parameter.merge('command' => @command) unless @command == nil
|
34
|
+
parameter = parameter.merge('version' => @version) unless @version == nil || @version == ""
|
35
|
+
parameter = parameter.merge('parameter' => @parameter) unless @parameter == nil || @parameter == ""
|
36
|
+
|
37
|
+
leancloud_file = @command.split("/").first
|
38
|
+
|
39
|
+
send_log_cloud(leancloud_file, parameter)
|
40
|
+
end
|
41
|
+
|
42
|
+
def send_log_cloud(file_name, parameter)
|
43
|
+
if file_name == nil
|
44
|
+
return
|
45
|
+
end
|
46
|
+
|
47
|
+
if BigkeeperParser.global_configs("LeanCloudId") == nil || BigkeeperParser.global_configs("LeanCloudKey") == nil
|
48
|
+
return
|
49
|
+
end
|
50
|
+
|
51
|
+
header = assemble_request
|
52
|
+
|
53
|
+
uri = URI.parse("https://api.leancloud.cn/1.1/classes/#{file_name}")
|
54
|
+
|
55
|
+
https = Net::HTTP.new(uri.host, 443)
|
56
|
+
https.use_ssl = true
|
57
|
+
https.ssl_version = :TLSv1
|
58
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
59
|
+
req = Net::HTTP::Post.new(uri.path, header)
|
60
|
+
req.body = parameter.to_json
|
61
|
+
res = https.request(req)
|
62
|
+
|
63
|
+
Logger.highlight("Send LeanCloud success, response #{res.body}")
|
64
|
+
end
|
65
|
+
|
66
|
+
def assemble_request
|
67
|
+
return {'Content-Type' =>'application/json', 'X-LC-Id' =>BigkeeperParser.global_configs("LeanCloudId"), 'X-LC-Key' =>BigkeeperParser.global_configs("LeanCloudKey")}
|
68
|
+
end
|
69
|
+
|
70
|
+
protected :send_log_cloud, :assemble_request
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'big_keeper/util/logger'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module BigKeeper
|
5
|
+
class ListGenerator
|
6
|
+
#generate tree print throught console
|
7
|
+
def self.generate_tree(file_path, home_branches, version)
|
8
|
+
module_branches_dic = {}
|
9
|
+
json_data = File.read(file_path)
|
10
|
+
module_branches_dic = JSON.parse(json_data)
|
11
|
+
to_tree(module_branches_dic, home_branches, version)
|
12
|
+
File.delete(file_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
#generate json print throught console
|
16
|
+
def self.generate_json(file_path, home_branches, version)
|
17
|
+
module_branches_dic = {}
|
18
|
+
json_data = File.read(file_path)
|
19
|
+
module_branches_dic = JSON.parse(json_data)
|
20
|
+
json = to_json(home_branches, module_branches_dic, version)
|
21
|
+
puts JSON.pretty_generate(json)
|
22
|
+
File.delete(file_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.to_json(home_branches, module_info_list, version)
|
26
|
+
json_array = []
|
27
|
+
print_all = version == "all versions"
|
28
|
+
home_branches = home_branches.uniq
|
29
|
+
home_branches.each do | home_branch_name |
|
30
|
+
next unless home_branch_name.include?(version) || print_all
|
31
|
+
branch_dic = {}
|
32
|
+
involve_modules = []
|
33
|
+
module_info_list.collect do | module_info_dic |
|
34
|
+
next unless module_info_dic["branches"] != nil
|
35
|
+
module_name = module_info_dic["module_name"]
|
36
|
+
module_info_dic["branches"].each do | module_branch |
|
37
|
+
if module_branch.strip.delete("*") == home_branch_name.strip.delete("*")
|
38
|
+
module_current_info = {}
|
39
|
+
module_current_info["module_name"] = module_name
|
40
|
+
module_current_info["current_branch"] = module_info_dic["current_branch"]
|
41
|
+
involve_modules << module_current_info
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
branch_dic["is_remote"] = false
|
47
|
+
branch_dic["is_current"] = false
|
48
|
+
|
49
|
+
if home_branch_name =~ /^remotes\//
|
50
|
+
home_branch_name = $~.post_match
|
51
|
+
branch_dic["is_remote"] = true
|
52
|
+
end
|
53
|
+
|
54
|
+
if home_branch_name =~ /^origin\//
|
55
|
+
home_branch_name = $~.post_match
|
56
|
+
end
|
57
|
+
|
58
|
+
if home_branch_name.include?("*")
|
59
|
+
home_branch_name = home_branch_name.delete("*")
|
60
|
+
branch_dic["is_current"] = true
|
61
|
+
end
|
62
|
+
|
63
|
+
if home_branch_name =~ /^feature\//
|
64
|
+
home_branch_name = $~.post_match
|
65
|
+
end
|
66
|
+
|
67
|
+
if home_branch_name =~ /^hotfix\//
|
68
|
+
home_branch_name = $~.post_match
|
69
|
+
end
|
70
|
+
|
71
|
+
branch_dic["home_branch_name"] = home_branch_name
|
72
|
+
branch_dic["involve_modules"] = involve_modules
|
73
|
+
json_array << branch_dic
|
74
|
+
end
|
75
|
+
json_array
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.to_tree(module_branches_dic, branches_name, version)
|
79
|
+
home_name = BigkeeperParser.home_name
|
80
|
+
print_all = version == "all versions"
|
81
|
+
branches_name.each do | home_branch_name |
|
82
|
+
next unless home_branch_name.include?(version) || print_all
|
83
|
+
Logger.highlight(home_branch_name.strip)
|
84
|
+
module_branches_dic.each do | module_info_dic |
|
85
|
+
module_name = module_info_dic["module_name"]
|
86
|
+
next if module_info_dic["branches"] == nil
|
87
|
+
module_info_dic["branches"].each do | module_branch |
|
88
|
+
if module_branch.include?(home_branch_name.strip.delete('*'))
|
89
|
+
if !module_branch.include?("*") && home_branch_name.include?("*")
|
90
|
+
Logger.warning(" ├── #{module_name} (current branch :#{module_info_dic["current_branch"]})")
|
91
|
+
else
|
92
|
+
Logger.default(" ├── #{module_name}")
|
93
|
+
end
|
94
|
+
break
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'big_keeper/util/leancloud_logger'
|
3
|
+
|
4
|
+
module BigKeeper
|
5
|
+
DEFAULT_LOG = 1
|
6
|
+
HIGHLIGHT_LOG = 2
|
7
|
+
ERROR_LOG = 3
|
8
|
+
WARNING_LOG = 4
|
9
|
+
|
10
|
+
class Logger
|
11
|
+
|
12
|
+
def self.log_with_type(sentence,type)
|
13
|
+
case type
|
14
|
+
when DEFAULT_LOG then puts sentence.to_s.colorize(:default)
|
15
|
+
when HIGHLIGHT_LOG then puts sentence.to_s.colorize(:green)
|
16
|
+
when ERROR_LOG then raise sentence.to_s.colorize(:red)
|
17
|
+
when WARNING_LOG then puts sentence.to_s.colorize(:yellow)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.default(sentence)
|
22
|
+
puts formatter_output(sentence).colorize(:default)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.highlight(sentence)
|
26
|
+
puts formatter_output(sentence).colorize(:green)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.error(sentence)
|
30
|
+
LeanCloudLogger.instance.end_log(false)
|
31
|
+
raise formatter_output(sentence).colorize(:red)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.warning(sentence)
|
35
|
+
puts formatter_output(sentence).colorize(:yellow)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.separator
|
39
|
+
puts "- - - - - - - - - - - - - - - - - - - - - - - - - - -".colorize(:light_blue)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.formatter_output(sentence)
|
43
|
+
"[big] ".concat(sentence.to_s).to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'big_keeper/util/logger'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
module BigKeeper
|
5
|
+
class PodOperator
|
6
|
+
def self.pod_install(path, repo_update)
|
7
|
+
# pod install
|
8
|
+
if repo_update
|
9
|
+
PodOperator.pod_update_private_repos(true)
|
10
|
+
end
|
11
|
+
Logger.highlight('Start pod install, waiting...')
|
12
|
+
cmd = "pod install --project-directory='#{path}'"
|
13
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
14
|
+
while line = stdout.gets
|
15
|
+
p line
|
16
|
+
end
|
17
|
+
end
|
18
|
+
Logger.highlight('Finish pod install.')
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.pod_repo_push(path, module_name, source, version)
|
22
|
+
Logger.highlight(%Q(Start Pod repo push #{module_name}))
|
23
|
+
Dir.chdir(path) do
|
24
|
+
command = ""
|
25
|
+
p BigkeeperParser.source_spec_name(module_name)
|
26
|
+
if source.length > 0
|
27
|
+
command = "pod repo push #{BigkeeperParser.source_spec_name(module_name)} #{module_name}.podspec --allow-warnings --sources=#{source} --verbose --use-libraries"
|
28
|
+
else
|
29
|
+
command = "pod repo push #{BigkeeperParser.source_spec_name(module_name)} #{module_name}.podspec --allow-warnings --verbose --use-libraries"
|
30
|
+
end
|
31
|
+
|
32
|
+
IO.popen(command) do |io|
|
33
|
+
is_success = false
|
34
|
+
error_info = Array.new
|
35
|
+
io.each do |line|
|
36
|
+
error_info.push(line)
|
37
|
+
is_success = true if line.include? "Updating spec repo"
|
38
|
+
end
|
39
|
+
unless is_success
|
40
|
+
puts error_info
|
41
|
+
Logger.error("Fail: '#{module_name}' Pod repo fail")
|
42
|
+
end
|
43
|
+
Logger.highlight(%Q(Success release #{module_name} V#{version}))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.pod_update_private_repos(update_private)
|
49
|
+
if update_private
|
50
|
+
BigkeeperParser.sources.map { |spec|
|
51
|
+
Logger.highlight('Start pod repo update, waiting...')
|
52
|
+
cmd = "pod repo update #{spec}"
|
53
|
+
cmd(cmd)
|
54
|
+
}
|
55
|
+
else
|
56
|
+
cmd = "pod repo update"
|
57
|
+
cmd(cmd)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.cmd(cmd)
|
62
|
+
Open3.popen3(cmd) do |stdin , stdout , stderr, wait_thr|
|
63
|
+
while line = stdout.gets
|
64
|
+
puts line
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'big_keeper/util/bigkeeper_parser'
|
2
|
+
require 'big_keeper/model/podfile_model'
|
3
|
+
require 'big_keeper/util/logger'
|
4
|
+
|
5
|
+
module BigKeeper
|
6
|
+
|
7
|
+
class PodfileDetector
|
8
|
+
|
9
|
+
attr_accessor :module_list, :main_path
|
10
|
+
$unlock_pod_list = []
|
11
|
+
$modify_pod_list = {}
|
12
|
+
|
13
|
+
def initialize(main_path, module_list)
|
14
|
+
@module_list = module_list
|
15
|
+
@main_path = main_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_unlock_pod_list
|
19
|
+
podfile_lines = File.readlines("#{@main_path}/Podfile")
|
20
|
+
Logger.highlight("Analyzing Podfile...") unless podfile_lines.size.zero?
|
21
|
+
podfile_lines.collect do |sentence|
|
22
|
+
deal_podfile_line(sentence) unless sentence =~(/(\d+.){1,2}\d+/)
|
23
|
+
end
|
24
|
+
$unlock_pod_list
|
25
|
+
end
|
26
|
+
|
27
|
+
def deal_podfile_line(sentence)
|
28
|
+
return unless !sentence.strip.start_with?("#")
|
29
|
+
if sentence.strip.include?('pod ')
|
30
|
+
pod_model = PodfileModel.new(sentence)
|
31
|
+
if !pod_model.name.empty? &&
|
32
|
+
pod_model.configurations != '[\'Debug\']' &&
|
33
|
+
pod_model.path == nil &&
|
34
|
+
pod_model.tag == nil
|
35
|
+
$unlock_pod_list << pod_model.name unless @module_list.include?(pod_model.name)
|
36
|
+
end
|
37
|
+
pod_model
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def deal_lock_file(main_path, deal_list)
|
43
|
+
$result = {}
|
44
|
+
podfile_lock_lines = File.readlines("#{main_path}/Podfile.lock")
|
45
|
+
Logger.highlight("Analyzing Podfile.lock...") unless podfile_lock_lines.size.zero?
|
46
|
+
podfile_lock_lines.select do |sentence|
|
47
|
+
if sentence.include?('DEPENDENCIES') #指定范围解析 Dependencies 之前
|
48
|
+
break
|
49
|
+
end
|
50
|
+
|
51
|
+
temp_sentence = sentence.strip
|
52
|
+
pod_name = get_lock_podname(temp_sentence)
|
53
|
+
if deal_list.include?(pod_name)
|
54
|
+
current_version = $result[pod_name]
|
55
|
+
temp_version = get_lock_version(temp_sentence)
|
56
|
+
if temp_version != nil
|
57
|
+
if current_version != nil
|
58
|
+
$result[pod_name] = chose_version(current_version, temp_version)
|
59
|
+
else
|
60
|
+
$result[pod_name] = temp_version
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
return $result
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.get_pod_model(sentence)
|
69
|
+
if sentence.include?('pod ')
|
70
|
+
pod_model = PodfileModel.new(sentence)
|
71
|
+
return pod_model
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_pod_name(sentence)
|
76
|
+
pod_model = deal_podfile_line(sentence)
|
77
|
+
pod_name = pod_model.name if pod_model != nil && pod_model.configurations.nil
|
78
|
+
@unlock_pod_list << pod_name unless @module_list.include pod_name
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
def get_lock_podname(sentence) #获得pod名称
|
84
|
+
match_result = /(\d+.){1,2}\d+/.match(sentence.delete('- :~>='))
|
85
|
+
pod_name = match_result.pre_match unless match_result == nil
|
86
|
+
return pod_name.delete('()') unless pod_name == nil
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_lock_version(sentence)#获得pod版本号
|
90
|
+
match_result = /(\d+.){1,2}\d+/.match(sentence)
|
91
|
+
return match_result[0] unless match_result == nil
|
92
|
+
end
|
93
|
+
|
94
|
+
def chose_version(cur_version,temp_version)
|
95
|
+
# p "cur:#{cur_version},temp:#{temp_version}"
|
96
|
+
cur_list = cur_version.split('.')
|
97
|
+
temp_list = temp_version.split('.')
|
98
|
+
temp_list << 0.to_s if temp_list.size == 2
|
99
|
+
if cur_list[0] >= temp_list[0]
|
100
|
+
if cur_list[1] >= temp_list[1]
|
101
|
+
if cur_list[2] > temp_list[2]
|
102
|
+
return cur_version
|
103
|
+
end
|
104
|
+
return temp_version
|
105
|
+
end
|
106
|
+
return temp_version
|
107
|
+
end
|
108
|
+
return temp_version
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|