kookeeper 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.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,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,116 @@
|
|
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
|
+
file << @modules.to_json
|
113
|
+
file.close
|
114
|
+
end
|
115
|
+
end
|
116
|
+
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
|
@@ -0,0 +1,221 @@
|
|
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 -xdf`
|
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
|
+
`git config user.name`.chop
|
131
|
+
end
|
132
|
+
|
133
|
+
def tag(path, version)
|
134
|
+
tags = Array.new
|
135
|
+
IO.popen("cd '#{path}'; git tag") do |io|
|
136
|
+
io.each do |line|
|
137
|
+
tags << line
|
138
|
+
end
|
139
|
+
end
|
140
|
+
unless tags.include? "#{version}\n"
|
141
|
+
Dir.chdir(path) do
|
142
|
+
`git tag -a #{version} -m "release: V #{version}" master;`
|
143
|
+
`git push --tags`
|
144
|
+
end
|
145
|
+
return
|
146
|
+
end
|
147
|
+
Logger.highlight("tag already exists in the remote, skip this step")
|
148
|
+
end
|
149
|
+
|
150
|
+
def tag_list(path)
|
151
|
+
tag_list = Array.new
|
152
|
+
IO.popen("cd '#{path}'; git tag -l") do |io|
|
153
|
+
io.each do |line|
|
154
|
+
unless line=~(/[a-zA-Z]/)
|
155
|
+
tag_list << line
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
tag_list
|
160
|
+
end
|
161
|
+
|
162
|
+
def check_merge(path, condition)
|
163
|
+
unmerged_branch = Array.new
|
164
|
+
IO.popen("cd '#{path}'; git branch --no-merged") do |io|
|
165
|
+
io.each do |line|
|
166
|
+
unmerged_branch.push(line) if line.include? "#{condition}"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
if (unmerged_branch.size > 0)
|
170
|
+
unmerged_branch.map { |item|
|
171
|
+
Logger.default(item)
|
172
|
+
}
|
173
|
+
Logger.error("Still has unmerged feature branch, please check")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def check_diff(path, branch, compare_branch)
|
178
|
+
compare_branch_commits = Array.new
|
179
|
+
IO.popen("cd '#{path}'; git log --left-right #{branch}...#{compare_branch} --pretty=oneline") do |io|
|
180
|
+
io.each do |line|
|
181
|
+
compare_branch_commits.push(line) if (line.include? '>') && (line.include? "Merge branch #{branch} into #{compare_branch}")
|
182
|
+
end
|
183
|
+
end
|
184
|
+
if compare_branch_commits.size > 0
|
185
|
+
compare_branch_commits.map { |item|
|
186
|
+
Logger.default(item)
|
187
|
+
}
|
188
|
+
Logger.error("#{compare_branch} branch has commit doesn't committed in #{branch}, please check")
|
189
|
+
else
|
190
|
+
Logger.highlight("#{compare_branch} branch doesn't have commit before #{branch}")
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def merge(path, branch_name)
|
195
|
+
IO.popen("cd '#{path}'; git merge #{branch_name}") do |line|
|
196
|
+
Logger.error("Merge conflict in #{branch_name}") if line.include? 'Merge conflict'
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def check_push_success(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? 'fatal')
|
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("#{branch} branch push unsuccess, please check")
|
212
|
+
else
|
213
|
+
Logger.highlight("#{branch} branch push success")
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
# p GitOperator.new.user
|
220
|
+
# BigStash::StashOperator.new("/Users/mmoaay/Documents/eleme/BigKeeperMain").list
|
221
|
+
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
|