kookeeper 3.0.2 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/.gitignore +8 -0
  3. data/.idea/bigkeeper.iml +68 -0
  4. data/.idea/modules.xml +8 -0
  5. data/.idea/vcs.xml +6 -0
  6. data/CODE_OF_CONDUCT.md +46 -0
  7. data/CONTRIBUTING.md +70 -0
  8. data/Gemfile +10 -0
  9. data/Gemfile.lock +145 -0
  10. data/LICENSE +21 -0
  11. data/README.md +113 -0
  12. data/big_keeper.gemspec +50 -0
  13. data/docs/en-US/FEATURE.md +0 -0
  14. data/docs/en-US/README.md +54 -0
  15. data/docs/zh-CN/BIGKEEPER_FILE.md +84 -0
  16. data/docs/zh-CN/FEATURE&HOTFIX.md +88 -0
  17. data/docs/zh-CN/IMAGE.md +0 -0
  18. data/docs/zh-CN/PODFILE.md +43 -0
  19. data/docs/zh-CN/README.md +113 -0
  20. data/docs/zh-CN/RECOMMEND.md +22 -0
  21. data/docs/zh-CN/RELEASE.md +60 -0
  22. data/docs/zh-CN/SPEC.md +39 -0
  23. data/lib/big_keeper/command/feature&hotfix/delete.rb +40 -0
  24. data/lib/big_keeper/command/feature&hotfix/finish.rb +54 -0
  25. data/lib/big_keeper/command/feature&hotfix/list.rb +63 -0
  26. data/lib/big_keeper/command/feature&hotfix/publish.rb +56 -0
  27. data/lib/big_keeper/command/feature&hotfix/pull.rb +26 -0
  28. data/lib/big_keeper/command/feature&hotfix/push.rb +27 -0
  29. data/lib/big_keeper/command/feature&hotfix/rebase.rb +32 -0
  30. data/lib/big_keeper/command/feature&hotfix/start.rb +89 -0
  31. data/lib/big_keeper/command/feature&hotfix/switch.rb +46 -0
  32. data/lib/big_keeper/command/feature&hotfix/update.rb +71 -0
  33. data/lib/big_keeper/command/feature&hotfix.rb +167 -0
  34. data/lib/big_keeper/command/image/image.rb +0 -0
  35. data/lib/big_keeper/command/image.rb +28 -0
  36. data/lib/big_keeper/command/pod/podfile.rb +69 -0
  37. data/lib/big_keeper/command/pod.rb +42 -0
  38. data/lib/big_keeper/command/release/home.rb +91 -0
  39. data/lib/big_keeper/command/release/module.rb +61 -0
  40. data/lib/big_keeper/command/release.rb +75 -0
  41. data/lib/big_keeper/command/spec/add.rb +9 -0
  42. data/lib/big_keeper/command/spec/analyze.rb +88 -0
  43. data/lib/big_keeper/command/spec/delete.rb +9 -0
  44. data/lib/big_keeper/command/spec/list.rb +19 -0
  45. data/lib/big_keeper/command/spec/search.rb +9 -0
  46. data/lib/big_keeper/command/spec/sync.rb +12 -0
  47. data/lib/big_keeper/command/spec.rb +78 -0
  48. data/lib/big_keeper/dependency/dep_gradle_operator.rb +56 -0
  49. data/lib/big_keeper/dependency/dep_operator.rb +32 -0
  50. data/lib/big_keeper/dependency/dep_pod_operator.rb +130 -0
  51. data/lib/big_keeper/dependency/dep_service.rb +14 -0
  52. data/lib/big_keeper/dependency/dep_type.rb +33 -0
  53. data/lib/big_keeper/model/gitflow_type.rb +43 -0
  54. data/lib/big_keeper/model/library_model.rb +116 -0
  55. data/lib/big_keeper/model/operate_type.rb +27 -0
  56. data/lib/big_keeper/model/podfile_model.rb +33 -0
  57. data/lib/big_keeper/service/git_service.rb +259 -0
  58. data/lib/big_keeper/service/module_service.rb +159 -0
  59. data/lib/big_keeper/service/stash_service.rb +58 -0
  60. data/lib/big_keeper/util/bigkeeper_parser.rb +244 -0
  61. data/lib/big_keeper/util/cache_operator.rb +117 -0
  62. data/lib/big_keeper/util/code_operator.rb +37 -0
  63. data/lib/big_keeper/util/file_operator.rb +33 -0
  64. data/lib/big_keeper/util/git_operator.rb +226 -0
  65. data/lib/big_keeper/util/gitflow_operator.rb +51 -0
  66. data/lib/big_keeper/util/gradle_operator.rb +209 -0
  67. data/lib/big_keeper/util/info_plist_operator.rb +46 -0
  68. data/lib/big_keeper/util/leancloud_logger.rb +72 -0
  69. data/lib/big_keeper/util/list_generator.rb +101 -0
  70. data/lib/big_keeper/util/logger.rb +46 -0
  71. data/lib/big_keeper/util/pod_operator.rb +71 -0
  72. data/lib/big_keeper/util/podfile_detector.rb +111 -0
  73. data/lib/big_keeper/util/podfile_module.rb +63 -0
  74. data/lib/big_keeper/util/podfile_operator.rb +117 -0
  75. data/lib/big_keeper/util/verify_operator.rb +17 -0
  76. data/lib/big_keeper/util/xcode_operator.rb +15 -0
  77. data/lib/big_keeper/version.rb +3 -0
  78. data/lib/big_keeper.rb +71 -0
  79. data/resources/banner.png +0 -0
  80. data/resources/command.png +0 -0
  81. data/resources/keynote/big-keeper-readme-analyze.key +0 -0
  82. data/resources/keynote/big-keeper-readme-example.key +0 -0
  83. data/resources/keynote/big-keeper-readme-feature.key +0 -0
  84. data/resources/keynote/big-keeper-readme-release.key +0 -0
  85. data/resources/readme/big-keeper-readme.001.png +0 -0
  86. metadata +86 -3
@@ -0,0 +1,226 @@
1
+ require 'big_keeper/util/logger'
2
+
3
+ module BigKeeper
4
+ # Operator for got
5
+ class GitOperator
6
+ def current_branch(path)
7
+ Dir.chdir(path) do
8
+ `git rev-parse --abbrev-ref HEAD`.chop
9
+ end
10
+ end
11
+
12
+ def has_remote_branch(path, branch_name)
13
+ has_branch = false
14
+ IO.popen("cd '#{path}'; git branch -r") do |io|
15
+ io.each do |line|
16
+ has_branch = true if line.include? branch_name
17
+ end
18
+ end
19
+ has_branch
20
+ end
21
+
22
+ def has_local_branch(path, branch_name)
23
+ has_branch = false
24
+ IO.popen("cd '#{path}'; git branch") do |io|
25
+ io.each do |line|
26
+ has_branch = true if line.include? branch_name
27
+ end
28
+ end
29
+ has_branch
30
+ end
31
+
32
+ def has_branch(path, branch_name)
33
+ has_branch = false
34
+ IO.popen("cd '#{path}'; git branch -a") do |io|
35
+ io.each do |line|
36
+ has_branch = true if line.include? branch_name
37
+ end
38
+ end
39
+ has_branch
40
+ end
41
+
42
+ def checkout(path, branch_name)
43
+ Dir.chdir(path) do
44
+ p "----------cd:#{path}"
45
+ p "----------git checkout #{branch_name}"
46
+ IO.popen("git checkout #{branch_name}") do |io|
47
+ io.each do |line|
48
+ Logger.error("Checkout #{branch_name} failed.") if line.include? 'error'
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ def fetch(path)
55
+ Dir.chdir(path) do
56
+ `git fetch origin`
57
+ end
58
+ end
59
+
60
+ def rebase(path, branch_name)
61
+ Dir.chdir(path) do
62
+ `git rebase origin/#{branch_name}`
63
+ end
64
+ end
65
+
66
+ def clone(path, git_base)
67
+ Dir.chdir(path) do
68
+ `git clone #{git_base}`
69
+ end
70
+ end
71
+
72
+ def commit(path, message)
73
+ Dir.chdir(path) do
74
+ `git add .`
75
+ `git commit -m "#{Logger.formatter_output(message)}"`
76
+ end
77
+ end
78
+
79
+ def push_to_remote(path, branch_name)
80
+ Dir.chdir(path) do
81
+ p "git push -u origin #{branch_name}"
82
+ `git push -u origin #{branch_name}`
83
+ end
84
+ GitOperator.new.check_push_success(path, branch_name, "origin/#{branch_name}")
85
+ end
86
+
87
+ def pull(path)
88
+ Dir.chdir(path) do
89
+ p "----------cd:#{path}"
90
+ p "----------git pull"
91
+ `git pull`
92
+ end
93
+ end
94
+
95
+ def has_commits(path, branch_name)
96
+ has_commits = false
97
+ IO.popen("cd '#{path}'; git log --branches --not --remotes") do |io|
98
+ io.each do |line|
99
+ has_commits = true if line.include? "(#{branch_name})"
100
+ end
101
+ end
102
+ has_commits
103
+ end
104
+
105
+ def has_changes(path)
106
+ has_changes = true
107
+ clear_flag = 'nothing to commit, working tree clean'
108
+ IO.popen("cd '#{path}'; git status") do |io|
109
+ io.each do |line|
110
+ has_changes = false if line.include? clear_flag
111
+ end
112
+ end
113
+ has_changes
114
+ end
115
+
116
+ def discard(path)
117
+ Dir.chdir(path) do
118
+ `git checkout . && git clean -xdf`
119
+ end
120
+ end
121
+
122
+ def del_local(path, branch_name)
123
+ Dir.chdir(path) do
124
+ `git branch -D #{branch_name}`
125
+ end
126
+ end
127
+
128
+ def del_remote(path, branch_name)
129
+ Dir.chdir(path) do
130
+ `git push origin --delete #{branch_name}`
131
+ end
132
+ end
133
+
134
+ def user
135
+ `git config user.name`.chop
136
+ end
137
+
138
+ def tag(path, version)
139
+ tags = Array.new
140
+ IO.popen("cd '#{path}'; git tag") do |io|
141
+ io.each do |line|
142
+ tags << line
143
+ end
144
+ end
145
+ unless tags.include? "#{version}\n"
146
+ Dir.chdir(path) do
147
+ `git tag -a #{version} -m "release: V #{version}" master;`
148
+ `git push --tags`
149
+ end
150
+ return
151
+ end
152
+ Logger.highlight("tag already exists in the remote, skip this step")
153
+ end
154
+
155
+ def tag_list(path)
156
+ tag_list = Array.new
157
+ IO.popen("cd '#{path}'; git tag -l") do |io|
158
+ io.each do |line|
159
+ unless line=~(/[a-zA-Z]/)
160
+ tag_list << line
161
+ end
162
+ end
163
+ end
164
+ tag_list
165
+ end
166
+
167
+ def check_merge(path, condition)
168
+ unmerged_branch = Array.new
169
+ IO.popen("cd '#{path}'; git branch --no-merged") do |io|
170
+ io.each do |line|
171
+ unmerged_branch.push(line) if line.include? "#{condition}"
172
+ end
173
+ end
174
+ if (unmerged_branch.size > 0)
175
+ unmerged_branch.map { |item|
176
+ Logger.default(item)
177
+ }
178
+ Logger.error("Still has unmerged feature branch, please check")
179
+ end
180
+ end
181
+
182
+ def check_diff(path, branch, compare_branch)
183
+ compare_branch_commits = Array.new
184
+ IO.popen("cd '#{path}'; git log --left-right #{branch}...#{compare_branch} --pretty=oneline") do |io|
185
+ io.each do |line|
186
+ compare_branch_commits.push(line) if (line.include? '>') && (line.include? "Merge branch #{branch} into #{compare_branch}")
187
+ end
188
+ end
189
+ if compare_branch_commits.size > 0
190
+ compare_branch_commits.map { |item|
191
+ Logger.default(item)
192
+ }
193
+ Logger.error("#{compare_branch} branch has commit doesn't committed in #{branch}, please check")
194
+ else
195
+ Logger.highlight("#{compare_branch} branch doesn't have commit before #{branch}")
196
+ end
197
+ end
198
+
199
+ def merge(path, branch_name)
200
+ IO.popen("cd '#{path}'; git merge #{branch_name}") do |line|
201
+ Logger.error("Merge conflict in #{branch_name}") if line.include? 'Merge conflict'
202
+ end
203
+ end
204
+
205
+ def check_push_success(path, branch, compare_branch)
206
+ compare_branch_commits = Array.new
207
+ IO.popen("cd '#{path}'; git log --left-right #{branch}...#{compare_branch} --pretty=oneline") do |io|
208
+ io.each do |line|
209
+ compare_branch_commits.push(line) if (line.include? '>') || (line.include? 'fatal')
210
+ end
211
+ end
212
+ if compare_branch_commits.size > 0
213
+ compare_branch_commits.map { |item|
214
+ Logger.default(item)
215
+ }
216
+ Logger.error("#{branch} branch push unsuccess, please check")
217
+ else
218
+ Logger.highlight("#{branch} branch push success")
219
+ end
220
+ end
221
+
222
+ end
223
+
224
+ # p GitOperator.new.user
225
+ # BigStash::StashOperator.new("/Users/mmoaay/Documents/eleme/BigKeeperMain").list
226
+ end
@@ -0,0 +1,51 @@
1
+ require 'big_keeper/model/gitflow_type'
2
+
3
+ module BigKeeper
4
+ # Operator for gitflow
5
+ class GitflowOperator
6
+ def start(path, name, type)
7
+ Dir.chdir(path) do
8
+ gitflow_type_name = GitflowType.name(type)
9
+ `git flow #{gitflow_type_name} start #{name}`
10
+ end
11
+ end
12
+
13
+ def verify_git_flow_command
14
+ has_git_flow_command = false
15
+ IO.popen('command -v git-flow') do |io|
16
+ io.each do |line|
17
+ has_git_flow_command = true
18
+ end
19
+ end
20
+ has_git_flow_command
21
+ end
22
+
23
+ def verify_git_flow(path)
24
+ has_git_flow = false
25
+ Dir.chdir(path) do
26
+ clear_flag = 'Already initialized for gitflow'
27
+ IO.popen('git flow init -d') do |io|
28
+ io.each do |line|
29
+ if line.include? clear_flag
30
+ has_git_flow = true
31
+ break
32
+ end
33
+ end
34
+ end
35
+ end
36
+ has_git_flow
37
+ end
38
+
39
+ def finish_release(path, release_name)
40
+ Dir.chdir(path) do
41
+ p `git checkout master`
42
+ p `git merge release/#{release_name}`
43
+ p `git push`
44
+ p `git checkout develop`
45
+ p `git merge release/#{release_name}`
46
+ p `git push`
47
+ p `git branch -d release/#{release_name}`
48
+ end
49
+ end
50
+ end
51
+ end
@@ -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