kookeeper 3.0.2 → 3.0.5

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.
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,58 @@
1
+ require 'big_stash/stash_operator'
2
+ require 'big_keeper/util/bigkeeper_parser'
3
+ require 'big_keeper/util/git_operator'
4
+ require 'big_keeper/util/logger'
5
+
6
+ module BigKeeper
7
+ # Operator for got
8
+ class StashService
9
+ def pop_stash(path, branch_name, name)
10
+ # pop stash
11
+ if BigStash::StashOperator.new(path).stash_for_name(branch_name)
12
+ Logger.highlight(%Q(Branch '#{branch_name}' of '#{name}' has stash , start to pop...))
13
+ BigStash::StashOperator.new(path).pop_stash(branch_name)
14
+ end
15
+ end
16
+
17
+ def stash(path, branch_name, name)
18
+ # stash
19
+ if GitOperator.new.has_changes(path)
20
+ Logger.highlight(%Q(Branch '#{branch_name}' of '#{name}' needs stash , start to stash...))
21
+ BigStash::StashOperator.new(path).stash(branch_name)
22
+ end
23
+ end
24
+
25
+ def stash_all(path, new_branch_name, user, modules,version)
26
+ # Stash modules
27
+ Logger.highlight('Stash for current workspace...')
28
+ p "--------------------9.1.Stash modules----------"
29
+ modules.each do |module_name|
30
+ module_path = BigkeeperParser.module_full_path(path, user, module_name)
31
+ branch_name = GitOperator.new.current_branch(module_path)
32
+
33
+ p "------------------------------module_path:#{module_path}"
34
+ p "------------------------------branch_name:#{branch_name}"
35
+ p "------------------------------new_branch_name:#{new_branch_name}"
36
+ if branch_name != new_branch_name
37
+ stash(module_path, branch_name, module_name)
38
+ end
39
+ end
40
+ p "--------------------end Stash modules----------"
41
+ # Stash home
42
+ branch_name = GitOperator.new.current_branch(path)
43
+ p "--------------------9.2.Stash home----------"
44
+
45
+
46
+ home_branch_name = "release/#{version}"
47
+
48
+ p "------------------------------branch_name:#{branch_name}"
49
+ p "------------------------------home_branch_name:#{home_branch_name}"
50
+
51
+ if branch_name != home_branch_name
52
+ stash(path, branch_name, 'Home')
53
+ end
54
+
55
+ p "--------------------end Stash home----------"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,244 @@
1
+ require 'big_keeper/util/logger'
2
+ require 'big_keeper/util/file_operator'
3
+
4
+ # Bigkeeper module
5
+ module BigKeeper
6
+ def self.version(name)
7
+ BigkeeperParser.parse_version(name)
8
+ end
9
+
10
+ def self.user(name)
11
+ BigkeeperParser.parse_user(name)
12
+ yield if block_given?
13
+ end
14
+
15
+ def self.home(name, params)
16
+ BigkeeperParser.parse_home(name, params)
17
+ end
18
+
19
+ def self.mod(name, params)
20
+ BigkeeperParser.parse_mod(name, params)
21
+ end
22
+
23
+ def self.modules
24
+ BigkeeperParser.parse_modules
25
+ yield if block_given?
26
+ end
27
+
28
+ def self.source(name)
29
+ BigkeeperParser.parse_source(name)
30
+ yield if block_given?
31
+ end
32
+
33
+ def self.configs
34
+ BigkeeperParser.parse_configs
35
+ yield if block_given?
36
+ end
37
+
38
+ def self.param(key, value)
39
+ BigkeeperParser.parse_param(key, value)
40
+ yield if block_given?
41
+ end
42
+
43
+ # Bigkeeper file parser
44
+ class BigkeeperParser
45
+ @@config = {}
46
+ @@current_user = ''
47
+
48
+ def self.parse(bigkeeper)
49
+ if @@config.empty?
50
+
51
+ Logger.error("Can't find a Bigkeeper file in current directory.") if !FileOperator.definitely_exists?(bigkeeper)
52
+
53
+ content = File.read bigkeeper
54
+ content.gsub!(/version\s/, 'BigKeeper::version ')
55
+ content.gsub!(/user\s/, 'BigKeeper::user ')
56
+ content.gsub!(/home\s/, 'BigKeeper::home ')
57
+ content.gsub!(/source\s/, 'BigKeeper::source ')
58
+ content.gsub!(/mod\s/, 'BigKeeper::mod ')
59
+ content.gsub!(/modules\s/, 'BigKeeper::modules ')
60
+ content.gsub!(/configs\s/, 'BigKeeper::configs ')
61
+ content.gsub!(/param\s/, 'BigKeeper::param ')
62
+ eval content
63
+ end
64
+ end
65
+
66
+ def self.parse_source(name)
67
+ @@config.delete("tmp_spec")
68
+ source_split = name.split(",") unless name.split(",").length != 2
69
+ if source_split != nil
70
+ sources = Hash["#{source_split[1].lstrip}" => "#{source_split[0]}"]
71
+ @@config[:source] = sources
72
+ @@config[:tmp_spec] = source_split[1].lstrip
73
+ end
74
+ end
75
+
76
+ def self.parse_version(name)
77
+ @@config[:version] = name
78
+ end
79
+
80
+ def self.parse_user(name)
81
+ @@current_user = name
82
+ users = @@config[:users]
83
+ users = {} if users.nil?
84
+ users[name] = {}
85
+ @@config[:users] = users
86
+ end
87
+
88
+ def self.parse_home(name, params)
89
+ @@config[:home] = params
90
+ @@config[:name] = name
91
+ end
92
+
93
+ def self.parse_mod(name, params)
94
+ if params[:path]
95
+ parse_user_mod(name, params)
96
+ elsif params[:git]
97
+ parse_modules_mod(name, params)
98
+ else
99
+ Logger.error(%(There should be ':path =>' or ':git =>' ':alias =>' for mod #{name}))
100
+ end
101
+ end
102
+
103
+ def self.parse_user_mod(name, params)
104
+ users = @@config[:users]
105
+ user = users[@@current_user]
106
+ mods = user[:mods]
107
+ mods = {} if mods.nil?
108
+ mods[name] = params
109
+ user[:mods] = mods
110
+ @@config[:users] = users
111
+ end
112
+
113
+ def self.parse_modules_mod(name, params)
114
+ if @@config[:source] != nil
115
+ params[:spec] = "#{@@config[:tmp_spec]}"
116
+ end
117
+ modules = @@config[:modules]
118
+ modules[name] = params
119
+ @@config[:modules] = modules
120
+ end
121
+
122
+ def self.parse_modules
123
+ modules = @@config[:modules]
124
+ modules = {} if modules.nil?
125
+ @@config[:modules] = modules
126
+ end
127
+
128
+ def self.parse_configs
129
+ @@config[:configs] = {}
130
+ end
131
+
132
+ def self.parse_param(key, value)
133
+ @@config[:configs] = @@config[:configs].merge(key => value)
134
+ end
135
+
136
+ def self.version
137
+ @@config[:version]
138
+ end
139
+
140
+ def self.home_name
141
+ @@config[:name]
142
+ end
143
+
144
+ def self.home_git()
145
+ @@config[:home][:git]
146
+ end
147
+
148
+ def self.home_modules_workspace()
149
+ if @@config[:home][:modules_workspace]
150
+ home_modules_workspace = @@config[:home][:modules_workspace]
151
+ if home_modules_workspace.rindex('/') != home_modules_workspace.length - 1
152
+ home_modules_workspace = home_modules_workspace + '/'
153
+ end
154
+
155
+ home_modules_workspace
156
+ else
157
+ '../'
158
+ end
159
+ end
160
+
161
+ def self.home_pulls()
162
+ @@config[:home][:pulls]
163
+ end
164
+
165
+ def self.source_spec_path(module_name)
166
+ spec = @@config[:modules][module_name][:spec]
167
+ @@config[:source][spec]
168
+ end
169
+
170
+ def self.source_spec_name(module_name)
171
+ spec = @@config[:modules][module_name][:spec]
172
+ end
173
+
174
+ def self.sources
175
+ @@config[:source].keys
176
+ end
177
+
178
+ def self.global_configs(key)
179
+ if @@config[:configs] == nil
180
+ return
181
+ end
182
+ @@config[:configs][key]
183
+ end
184
+
185
+ def self.module_full_path(home_path, user_name, module_name)
186
+ if @@config[:users] \
187
+ && @@config[:users][user_name] \
188
+ && @@config[:users][user_name][:mods] \
189
+ && @@config[:users][user_name][:mods][module_name] \
190
+ && @@config[:users][user_name][:mods][module_name][:path]
191
+ File.expand_path(@@config[:users][user_name][:mods][module_name][:path])
192
+ else
193
+ if @@config[:modules][module_name][:alias]
194
+ File.expand_path("#{home_path}/#{home_modules_workspace}/#{@@config[:modules][module_name][:alias]}")
195
+ else
196
+ File.expand_path("#{home_path}/#{home_modules_workspace}/#{module_name}")
197
+ end
198
+ end
199
+ end
200
+
201
+ def self.module_path(user_name, module_name)
202
+ if @@config[:users] \
203
+ && @@config[:users][user_name] \
204
+ && @@config[:users][user_name][:mods] \
205
+ && @@config[:users][user_name][:mods][module_name] \
206
+ && @@config[:users][user_name][:mods][module_name][:path]
207
+ File.expand_path(@@config[:users][user_name][:mods][module_name][:path])
208
+ else
209
+ p @@config[:modules][module_name]
210
+ if @@config[:modules][module_name][:alias]
211
+ "#{home_modules_workspace}#{@@config[:modules][module_name][:alias]}"
212
+ else
213
+ "#{home_modules_workspace}#{module_name}"
214
+ end
215
+ end
216
+ end
217
+
218
+ def self.module_git(module_name)
219
+ @@config[:modules][module_name][:git]
220
+ end
221
+
222
+ def self.module_pulls(module_name)
223
+ @@config[:modules][module_name][:pulls]
224
+ end
225
+
226
+ def self.verify_modules(modules)
227
+ modules = [] unless modules
228
+ modules = modules.uniq
229
+ modules.each do |item|
230
+ Logger.error("Can not find module #{item} in Bigkeeper file") unless @@config[:modules][item]
231
+ end
232
+ modules
233
+ end
234
+
235
+ def self.module_names
236
+ @@config[:modules].keys
237
+ end
238
+
239
+ def self.config
240
+ @@config
241
+ end
242
+ end
243
+
244
+ end
@@ -0,0 +1,117 @@
1
+ require 'fileutils'
2
+ require 'json'
3
+
4
+ module BigKeeper
5
+ class CacheOperator
6
+ def initialize(path)
7
+ @path = File.expand_path(path)
8
+ @cache_path = File.expand_path("#{path}/.bigkeeper")
9
+ end
10
+
11
+ def save(file)
12
+ dest_path = File.dirname("#{@cache_path}/#{file}")
13
+ FileUtils.mkdir_p(dest_path) unless File.exist?(dest_path)
14
+ FileUtils.cp("#{@path}/#{file}", "#{@cache_path}/#{file}");
15
+ end
16
+
17
+ def load(file)
18
+ FileUtils.cp("#{@cache_path}/#{file}", "#{@path}/#{file}");
19
+ end
20
+
21
+ def clean
22
+ FileUtils.rm_r(@cache_path)
23
+ end
24
+ end
25
+
26
+ class ModuleCacheOperator
27
+ def initialize(path)
28
+ @cache_path = File.expand_path("#{path}/.bigkeeper")
29
+
30
+ FileUtils.mkdir_p(@cache_path) unless File.exist?(@cache_path)
31
+
32
+ if File.exist?("#{@cache_path}/module.cache")
33
+ file = File.open("#{@cache_path}/module.cache", 'r')
34
+ @modules = JSON.load(file.read())
35
+ file.close
36
+ else
37
+ @modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []}}
38
+ end
39
+ end
40
+
41
+ def all_path_modules
42
+ @modules["path"]["all"]
43
+ end
44
+
45
+ def add_path_modules
46
+ @modules["path"]["add"]
47
+ end
48
+
49
+ def del_path_modules
50
+ @modules["path"]["del"]
51
+ end
52
+
53
+ def current_path_modules
54
+ @modules["path"]["current"]
55
+ end
56
+
57
+ def remain_path_modules
58
+ @modules["path"]["all"] - @modules["path"]["current"]
59
+ end
60
+
61
+ def all_git_modules
62
+ @modules["git"]["all"]
63
+ end
64
+
65
+ def current_git_modules
66
+ @modules["git"]["current"]
67
+ end
68
+
69
+ def remain_git_modules
70
+ @modules["git"]["all"] - @modules["git"]["current"]
71
+ end
72
+
73
+ def cache_path_modules(modules, add_modules, del_modules)
74
+ @modules["path"]["all"] = modules.uniq
75
+ @modules["path"]["add"] = add_modules.uniq
76
+ @modules["path"]["del"] = del_modules.uniq
77
+ cache_modules
78
+ end
79
+
80
+ def cache_git_modules(modules)
81
+ @modules["git"]["all"] = modules.uniq
82
+ cache_modules
83
+ end
84
+
85
+ def add_git_module(module_name)
86
+ @modules["git"]["current"] << module_name unless @modules["git"]["current"].include?(module_name)
87
+ cache_modules
88
+ end
89
+
90
+ def del_git_module(module_name)
91
+ @modules["git"]["current"].delete(module_name) if @modules["git"]["current"].include?(module_name)
92
+ cache_modules
93
+ end
94
+
95
+ def add_path_module(module_name)
96
+ @modules["path"]["current"] << module_name unless @modules["path"]["current"].include?(module_name)
97
+ cache_modules
98
+ end
99
+
100
+ def del_path_module(module_name)
101
+ @modules["path"]["current"].delete(module_name) if @modules["path"]["current"].include?(module_name)
102
+ cache_modules
103
+ end
104
+
105
+ def clean_modules
106
+ @modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []}}
107
+ cache_modules
108
+ end
109
+
110
+ def cache_modules
111
+ file = File.new("#{@cache_path}/module.cache", 'w')
112
+ p "module缓存地址:#{@cache_path}/module.cache"
113
+ file << @modules.to_json
114
+ file.close
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,37 @@
1
+ module BigKeeper
2
+
3
+ class OCCodeOperator
4
+ end
5
+
6
+ class << OCCodeOperator
7
+
8
+ def in_note_code(line_hash)
9
+ line = line_hash["line"]
10
+ in_note = line_hash["in_note"]
11
+ line = line.strip
12
+ if in_note
13
+ line_hash["line"]=""
14
+ if (line.include?("*/"))
15
+ line_hash["in_note"] = false
16
+ end
17
+ return
18
+ end
19
+ if line[0,2] == "//" || line[0,7] == "#pragma"
20
+ line_hash["line"]=""
21
+ return
22
+ end
23
+ if line.include?("/*")
24
+ line_hash["in_note"] = true
25
+ before_line = line[line.index("/*")+1...line.size]
26
+ if before_line.include?("*/")
27
+ line_hash["in_note"] = false
28
+ end
29
+ line_hash["line"] = line[0,line.index("/*")]
30
+ return
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,33 @@
1
+ module BigKeeper
2
+ # Operator for got
3
+ class FileOperator
4
+ def self.definitely_exists? path
5
+ folder = File.dirname path
6
+ filename = File.basename path
7
+ # Unlike Ruby IO, ls, and find -f, this technique will fail to locate the file if the case is wrong:
8
+ not %x( find "#{folder}" -name "#{filename}" ).empty?
9
+ end
10
+
11
+ def find_all(path, name)
12
+ Dir.glob("#{path}/*/#{name}")
13
+ end
14
+
15
+ def current_username
16
+ current_name = `whoami`
17
+ current_name.chomp
18
+ end
19
+
20
+ end
21
+
22
+ class << FileOperator
23
+ def find_all_header_file(path)
24
+ return Dir.glob("#{path}/**/*.h")
25
+ end
26
+ def find_all_code_file(path)
27
+ header_file_list = Dir.glob("#{path}/**/*.[h]")
28
+ m_file_list = Dir.glob("#{path}/**/*.[m]")
29
+ return header_file_list+m_file_list
30
+ end
31
+ end
32
+
33
+ end