kookeeper 1.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +11 -110
- data/.github/ISSUE_TEMPLATE.md +0 -20
- data/.gitignore +0 -50
- data/.travis.yml +0 -19
- data/CODE_OF_CONDUCT.md +0 -46
- data/CONTRIBUTING.md +0 -70
- data/Gemfile +0 -10
- data/Gemfile.lock +0 -125
- data/LICENSE +0 -21
- data/README.md +0 -113
- data/Rakefile +0 -2
- data/big_keeper.gemspec +0 -49
- data/bin/big +0 -14
- data/bin/setup +0 -8
- data/docs/en-US/FEATURE.md +0 -0
- data/docs/en-US/README.md +0 -54
- data/docs/zh-CN/BIGKEEPER_FILE.md +0 -84
- data/docs/zh-CN/FEATURE&HOTFIX.md +0 -88
- data/docs/zh-CN/IMAGE.md +0 -0
- data/docs/zh-CN/PODFILE.md +0 -43
- data/docs/zh-CN/README.md +0 -113
- data/docs/zh-CN/RECOMMEND.md +0 -22
- data/docs/zh-CN/RELEASE.md +0 -60
- data/docs/zh-CN/SPEC.md +0 -39
- data/lib/big_keeper/command/client.rb +0 -50
- data/lib/big_keeper/command/feature&hotfix/delete.rb +0 -40
- data/lib/big_keeper/command/feature&hotfix/finish.rb +0 -54
- data/lib/big_keeper/command/feature&hotfix/list.rb +0 -63
- data/lib/big_keeper/command/feature&hotfix/publish.rb +0 -56
- data/lib/big_keeper/command/feature&hotfix/pull.rb +0 -26
- data/lib/big_keeper/command/feature&hotfix/push.rb +0 -27
- data/lib/big_keeper/command/feature&hotfix/rebase.rb +0 -32
- data/lib/big_keeper/command/feature&hotfix/start.rb +0 -74
- data/lib/big_keeper/command/feature&hotfix/switch.rb +0 -46
- data/lib/big_keeper/command/feature&hotfix/update.rb +0 -66
- data/lib/big_keeper/command/feature&hotfix.rb +0 -167
- data/lib/big_keeper/command/image/image.rb +0 -0
- data/lib/big_keeper/command/image.rb +0 -28
- data/lib/big_keeper/command/init.rb +0 -36
- data/lib/big_keeper/command/pod/podfile.rb +0 -72
- data/lib/big_keeper/command/pod.rb +0 -55
- data/lib/big_keeper/command/release/finish.rb +0 -36
- data/lib/big_keeper/command/release/home.rb +0 -92
- data/lib/big_keeper/command/release/module.rb +0 -65
- data/lib/big_keeper/command/release/publish.rb +0 -4
- data/lib/big_keeper/command/release/start.rb +0 -78
- data/lib/big_keeper/command/release.rb +0 -100
- data/lib/big_keeper/command/spec/add.rb +0 -9
- data/lib/big_keeper/command/spec/analyze.rb +0 -88
- data/lib/big_keeper/command/spec/delete.rb +0 -9
- data/lib/big_keeper/command/spec/list.rb +0 -19
- data/lib/big_keeper/command/spec/search.rb +0 -9
- data/lib/big_keeper/command/spec/sync.rb +0 -12
- data/lib/big_keeper/command/spec.rb +0 -78
- data/lib/big_keeper/dependency/dep_gradle_operator.rb +0 -74
- data/lib/big_keeper/dependency/dep_operator.rb +0 -48
- data/lib/big_keeper/dependency/dep_pod_operator.rb +0 -130
- data/lib/big_keeper/dependency/dep_service.rb +0 -14
- data/lib/big_keeper/dependency/dep_type.rb +0 -33
- data/lib/big_keeper/model/gitflow_type.rb +0 -43
- data/lib/big_keeper/model/library_model.rb +0 -116
- data/lib/big_keeper/model/operate_type.rb +0 -30
- data/lib/big_keeper/model/podfile_model.rb +0 -33
- data/lib/big_keeper/service/git_service.rb +0 -211
- data/lib/big_keeper/service/module_service.rb +0 -224
- data/lib/big_keeper/service/stash_service.rb +0 -45
- data/lib/big_keeper/util/bigkeeper_parser.rb +0 -260
- data/lib/big_keeper/util/cache_operator.rb +0 -118
- data/lib/big_keeper/util/code_operator.rb +0 -37
- data/lib/big_keeper/util/command_line_util.rb +0 -9
- data/lib/big_keeper/util/file_operator.rb +0 -33
- data/lib/big_keeper/util/git_operator.rb +0 -242
- data/lib/big_keeper/util/gitflow_operator.rb +0 -51
- data/lib/big_keeper/util/gradle_content_generator.rb +0 -26
- data/lib/big_keeper/util/gradle_file_operator.rb +0 -339
- data/lib/big_keeper/util/gradle_module_operator.rb +0 -70
- data/lib/big_keeper/util/info_plist_operator.rb +0 -46
- data/lib/big_keeper/util/leancloud_logger.rb +0 -84
- data/lib/big_keeper/util/list_generator.rb +0 -101
- data/lib/big_keeper/util/lockfile_parser.rb +0 -143
- data/lib/big_keeper/util/logger.rb +0 -47
- data/lib/big_keeper/util/pod_operator.rb +0 -70
- data/lib/big_keeper/util/podfile_detector.rb +0 -102
- data/lib/big_keeper/util/podfile_module.rb +0 -63
- data/lib/big_keeper/util/podfile_operator.rb +0 -125
- data/lib/big_keeper/util/verify_operator.rb +0 -17
- data/lib/big_keeper/util/version_config_operator.rb +0 -29
- data/lib/big_keeper/util/xcode_operator.rb +0 -15
- data/lib/big_keeper/version.rb +0 -3
- data/lib/big_keeper.rb +0 -81
- 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
- data/resources/template/Bigkeeper +0 -23
@@ -1,260 +0,0 @@
|
|
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, :encoding => 'UTF-8')
|
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_source(module_name)
|
223
|
-
@@config[:modules][module_name][:mod_path]
|
224
|
-
end
|
225
|
-
|
226
|
-
def self.module_maven(module_name)
|
227
|
-
@@config[:modules][module_name][:maven_group] + ':' + @@config[:modules][module_name][:maven_artifact]
|
228
|
-
end
|
229
|
-
|
230
|
-
def self.module_maven_artifact(module_name)
|
231
|
-
@@config[:modules][module_name][:maven_artifact]
|
232
|
-
end
|
233
|
-
|
234
|
-
def self.module_version_alias(module_name)
|
235
|
-
@@config[:modules][module_name][:version_alias]
|
236
|
-
end
|
237
|
-
|
238
|
-
def self.module_pulls(module_name)
|
239
|
-
@@config[:modules][module_name][:pulls]
|
240
|
-
end
|
241
|
-
|
242
|
-
def self.verify_modules(modules)
|
243
|
-
modules = [] unless modules
|
244
|
-
modules = modules.uniq
|
245
|
-
modules.each do |item|
|
246
|
-
Logger.error("Can not find module #{item} in Bigkeeper file") unless @@config[:modules][item]
|
247
|
-
end
|
248
|
-
modules
|
249
|
-
end
|
250
|
-
|
251
|
-
def self.module_names
|
252
|
-
@@config[:modules].keys
|
253
|
-
end
|
254
|
-
|
255
|
-
def self.config
|
256
|
-
@@config
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
end
|
@@ -1,118 +0,0 @@
|
|
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
|
-
if File.exist?(@cache_path)
|
23
|
-
FileUtils.rm_r(@cache_path)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class ModuleCacheOperator
|
29
|
-
def initialize(path)
|
30
|
-
@cache_path = File.expand_path("#{path}/.bigkeeper")
|
31
|
-
|
32
|
-
FileUtils.mkdir_p(@cache_path) unless File.exist?(@cache_path)
|
33
|
-
|
34
|
-
if File.exist?("#{@cache_path}/module.cache")
|
35
|
-
file = File.open("#{@cache_path}/module.cache", 'r', :encoding => 'UTF-8')
|
36
|
-
@modules = JSON.load(file.read(), :encoding => 'UTF-8')
|
37
|
-
file.close
|
38
|
-
else
|
39
|
-
@modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []}}
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def all_path_modules
|
44
|
-
@modules["path"]["all"]
|
45
|
-
end
|
46
|
-
|
47
|
-
def add_path_modules
|
48
|
-
@modules["path"]["add"]
|
49
|
-
end
|
50
|
-
|
51
|
-
def del_path_modules
|
52
|
-
@modules["path"]["del"]
|
53
|
-
end
|
54
|
-
|
55
|
-
def current_path_modules
|
56
|
-
@modules["path"]["current"]
|
57
|
-
end
|
58
|
-
|
59
|
-
def remain_path_modules
|
60
|
-
@modules["path"]["all"] - @modules["path"]["current"]
|
61
|
-
end
|
62
|
-
|
63
|
-
def all_git_modules
|
64
|
-
@modules["git"]["all"]
|
65
|
-
end
|
66
|
-
|
67
|
-
def current_git_modules
|
68
|
-
@modules["git"]["current"]
|
69
|
-
end
|
70
|
-
|
71
|
-
def remain_git_modules
|
72
|
-
@modules["git"]["all"] - @modules["git"]["current"]
|
73
|
-
end
|
74
|
-
|
75
|
-
def cache_path_modules(modules, add_modules, del_modules)
|
76
|
-
@modules["path"]["all"] = modules.uniq
|
77
|
-
@modules["path"]["add"] = add_modules.uniq
|
78
|
-
@modules["path"]["del"] = del_modules.uniq
|
79
|
-
cache_modules
|
80
|
-
end
|
81
|
-
|
82
|
-
def cache_git_modules(modules)
|
83
|
-
@modules["git"]["all"] = modules.uniq
|
84
|
-
cache_modules
|
85
|
-
end
|
86
|
-
|
87
|
-
def add_git_module(module_name)
|
88
|
-
@modules["git"]["current"] << module_name unless @modules["git"]["current"].include?(module_name)
|
89
|
-
cache_modules
|
90
|
-
end
|
91
|
-
|
92
|
-
def del_git_module(module_name)
|
93
|
-
@modules["git"]["current"].delete(module_name) if @modules["git"]["current"].include?(module_name)
|
94
|
-
cache_modules
|
95
|
-
end
|
96
|
-
|
97
|
-
def add_path_module(module_name)
|
98
|
-
@modules["path"]["current"] << module_name unless @modules["path"]["current"].include?(module_name)
|
99
|
-
cache_modules
|
100
|
-
end
|
101
|
-
|
102
|
-
def del_path_module(module_name)
|
103
|
-
@modules["path"]["current"].delete(module_name) if @modules["path"]["current"].include?(module_name)
|
104
|
-
cache_modules
|
105
|
-
end
|
106
|
-
|
107
|
-
def clean_modules
|
108
|
-
@modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []}}
|
109
|
-
cache_modules
|
110
|
-
end
|
111
|
-
|
112
|
-
def cache_modules
|
113
|
-
file = File.new("#{@cache_path}/module.cache", 'w', :encoding => 'UTF-8')
|
114
|
-
file << @modules.to_json
|
115
|
-
file.close
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,37 +0,0 @@
|
|
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
|
@@ -1,33 +0,0 @@
|
|
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
|
@@ -1,242 +0,0 @@
|
|
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
|
-
IO.popen("git checkout #{branch_name}") do |io|
|
45
|
-
io.each do |line|
|
46
|
-
Logger.error("Checkout #{branch_name} failed.") if line.include? 'error'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def fetch(path)
|
53
|
-
Dir.chdir(path) do
|
54
|
-
`git fetch origin`
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def rebase(path, branch_name)
|
59
|
-
Dir.chdir(path) do
|
60
|
-
`git rebase origin/#{branch_name}`
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def clone(path, git_base)
|
65
|
-
Dir.chdir(path) do
|
66
|
-
`git clone #{git_base}`
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def commit(path, message)
|
71
|
-
Dir.chdir(path) do
|
72
|
-
`git add .`
|
73
|
-
`git commit -m "#{Logger.formatter_output(message)}"`
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def push_to_remote(path, branch_name)
|
78
|
-
Dir.chdir(path) do
|
79
|
-
`git push -u origin #{branch_name}`
|
80
|
-
end
|
81
|
-
GitOperator.new.check_push_success(path, branch_name, "origin/#{branch_name}")
|
82
|
-
end
|
83
|
-
|
84
|
-
def pull(path)
|
85
|
-
Dir.chdir(path) do
|
86
|
-
`git pull`
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def has_commits(path, branch_name)
|
91
|
-
has_commits = false
|
92
|
-
IO.popen("cd '#{path}'; git log --branches --not --remotes") do |io|
|
93
|
-
io.each do |line|
|
94
|
-
has_commits = true if line.include? "(#{branch_name})"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
has_commits
|
98
|
-
end
|
99
|
-
|
100
|
-
def has_changes(path)
|
101
|
-
has_changes = true
|
102
|
-
clear_flag = 'nothing to commit, working tree clean'
|
103
|
-
IO.popen("cd '#{path}'; git status") do |io|
|
104
|
-
io.each do |line|
|
105
|
-
has_changes = false if line.include? clear_flag
|
106
|
-
end
|
107
|
-
end
|
108
|
-
has_changes
|
109
|
-
end
|
110
|
-
|
111
|
-
def discard(path)
|
112
|
-
Dir.chdir(path) do
|
113
|
-
`git checkout . && git clean -df`
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def del_local(path, branch_name)
|
118
|
-
Dir.chdir(path) do
|
119
|
-
`git branch -D #{branch_name}`
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def del_remote(path, branch_name)
|
124
|
-
Dir.chdir(path) do
|
125
|
-
`git push origin --delete #{branch_name}`
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def user
|
130
|
-
name = `git config user.name`.chop
|
131
|
-
cn_reg = /[\u4e00-\u9fa5]{1}/
|
132
|
-
cn_arr = name.scan(cn_reg)
|
133
|
-
if cn_arr.count > 0
|
134
|
-
Logger.error("git config user.name has Chinese character")
|
135
|
-
else
|
136
|
-
name.gsub(/[^0-9A-Za-z]/, '').downcase
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def tag(path, version)
|
141
|
-
tags = Array.new
|
142
|
-
IO.popen("cd '#{path}'; git tag") do |io|
|
143
|
-
io.each do |line|
|
144
|
-
tags << line
|
145
|
-
end
|
146
|
-
end
|
147
|
-
unless tags.include? "#{version}\n"
|
148
|
-
Dir.chdir(path) do
|
149
|
-
`git tag -a #{version} -m "release: V #{version}" master;`
|
150
|
-
`git push --tags`
|
151
|
-
end
|
152
|
-
return
|
153
|
-
end
|
154
|
-
Logger.highlight("tag already exists in the remote, skip this step")
|
155
|
-
end
|
156
|
-
|
157
|
-
def tag_list(path)
|
158
|
-
tag_list = Array.new
|
159
|
-
IO.popen("cd '#{path}'; git tag -l") do |io|
|
160
|
-
io.each do |line|
|
161
|
-
unless line=~(/[a-zA-Z]/)
|
162
|
-
tag_list << line
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
tag_list
|
167
|
-
end
|
168
|
-
|
169
|
-
def check_merge(path, condition)
|
170
|
-
unmerged_branch = Array.new
|
171
|
-
IO.popen("cd '#{path}'; git branch --no-merged") do |io|
|
172
|
-
io.each do |line|
|
173
|
-
unmerged_branch.push(line) if line.include? "#{condition}"
|
174
|
-
end
|
175
|
-
end
|
176
|
-
if (unmerged_branch.size > 0)
|
177
|
-
unmerged_branch.map { |item|
|
178
|
-
Logger.default(item)
|
179
|
-
}
|
180
|
-
Logger.error("Still has unmerged feature branch, please check")
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def check_remote_branch_diff(path, branch, compare_branch)
|
185
|
-
fetch(path)
|
186
|
-
compare_branch_commits = Array.new
|
187
|
-
IO.popen("cd '#{path}';git log --left-right #{branch}...origin/#{compare_branch} --pretty=oneline") do |io|
|
188
|
-
io.each do |line|
|
189
|
-
compare_branch_commits.push(line) unless (line.include? '>') && (line.include? "Merge branch \'#{branch}\'")
|
190
|
-
end
|
191
|
-
end
|
192
|
-
if compare_branch_commits.size > 0
|
193
|
-
return true
|
194
|
-
else
|
195
|
-
return false
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
# TODO: 需要改造,util方法不应该有业务逻辑
|
200
|
-
def check_diff(path, branch, compare_branch)
|
201
|
-
compare_branch_commits = Array.new
|
202
|
-
IO.popen("cd '#{path}'; git log --left-right #{branch}...#{compare_branch} --pretty=oneline") do |io|
|
203
|
-
io.each do |line|
|
204
|
-
compare_branch_commits.push(line) if (line.include? '>') && (line.include? "Merge branch #{branch} into #{compare_branch}")
|
205
|
-
end
|
206
|
-
end
|
207
|
-
if compare_branch_commits.size > 0
|
208
|
-
compare_branch_commits.map { |item|
|
209
|
-
Logger.default(item)
|
210
|
-
}
|
211
|
-
Logger.error("#{compare_branch} branch has commit doesn't committed in #{branch}, please check")
|
212
|
-
else
|
213
|
-
Logger.highlight("#{compare_branch} branch doesn't have commit before #{branch}")
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def merge(path, branch_name)
|
218
|
-
IO.popen("cd '#{path}'; git merge #{branch_name}") do |line|
|
219
|
-
Logger.error("Merge conflict in #{branch_name}") if line.include? 'Merge conflict'
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
def check_push_success(path, branch, compare_branch)
|
224
|
-
compare_branch_commits = Array.new
|
225
|
-
IO.popen("cd '#{path}'; git log --left-right #{branch}...#{compare_branch} --pretty=oneline") do |io|
|
226
|
-
io.each do |line|
|
227
|
-
compare_branch_commits.push(line) if (line.include? '>') || (line.include? 'fatal')
|
228
|
-
end
|
229
|
-
end
|
230
|
-
if compare_branch_commits.size > 0
|
231
|
-
compare_branch_commits.map { |item|
|
232
|
-
Logger.default(item)
|
233
|
-
}
|
234
|
-
Logger.error("#{branch} branch push unsuccess, please check")
|
235
|
-
else
|
236
|
-
Logger.highlight("#{branch} branch push success")
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
end
|
241
|
-
|
242
|
-
end
|