kookeeper 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/.gitignore +8 -0
- data/.idea/bigkeeper.iml +68 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/CONTRIBUTING.md +70 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +145 -0
- data/LICENSE +21 -0
- data/README.md +113 -0
- data/big_keeper.gemspec +50 -0
- data/docs/en-US/FEATURE.md +0 -0
- data/docs/en-US/README.md +54 -0
- data/docs/zh-CN/BIGKEEPER_FILE.md +84 -0
- data/docs/zh-CN/FEATURE&HOTFIX.md +88 -0
- data/docs/zh-CN/IMAGE.md +0 -0
- data/docs/zh-CN/PODFILE.md +43 -0
- data/docs/zh-CN/README.md +113 -0
- data/docs/zh-CN/RECOMMEND.md +22 -0
- data/docs/zh-CN/RELEASE.md +60 -0
- data/docs/zh-CN/SPEC.md +39 -0
- data/lib/big_keeper/command/feature&hotfix/delete.rb +40 -0
- data/lib/big_keeper/command/feature&hotfix/finish.rb +54 -0
- data/lib/big_keeper/command/feature&hotfix/list.rb +63 -0
- data/lib/big_keeper/command/feature&hotfix/publish.rb +56 -0
- data/lib/big_keeper/command/feature&hotfix/pull.rb +26 -0
- data/lib/big_keeper/command/feature&hotfix/push.rb +27 -0
- data/lib/big_keeper/command/feature&hotfix/rebase.rb +32 -0
- data/lib/big_keeper/command/feature&hotfix/start.rb +74 -0
- data/lib/big_keeper/command/feature&hotfix/switch.rb +46 -0
- data/lib/big_keeper/command/feature&hotfix/update.rb +66 -0
- data/lib/big_keeper/command/feature&hotfix.rb +167 -0
- data/lib/big_keeper/command/image/image.rb +0 -0
- data/lib/big_keeper/command/image.rb +28 -0
- data/lib/big_keeper/command/pod/podfile.rb +69 -0
- data/lib/big_keeper/command/pod.rb +42 -0
- data/lib/big_keeper/command/release/home.rb +91 -0
- data/lib/big_keeper/command/release/module.rb +61 -0
- data/lib/big_keeper/command/release.rb +75 -0
- data/lib/big_keeper/command/spec/add.rb +9 -0
- data/lib/big_keeper/command/spec/analyze.rb +88 -0
- data/lib/big_keeper/command/spec/delete.rb +9 -0
- data/lib/big_keeper/command/spec/list.rb +19 -0
- data/lib/big_keeper/command/spec/search.rb +9 -0
- data/lib/big_keeper/command/spec/sync.rb +12 -0
- data/lib/big_keeper/command/spec.rb +78 -0
- data/lib/big_keeper/dependency/dep_gradle_operator.rb +56 -0
- data/lib/big_keeper/dependency/dep_operator.rb +32 -0
- data/lib/big_keeper/dependency/dep_pod_operator.rb +130 -0
- data/lib/big_keeper/dependency/dep_service.rb +14 -0
- data/lib/big_keeper/dependency/dep_type.rb +33 -0
- data/lib/big_keeper/model/gitflow_type.rb +43 -0
- data/lib/big_keeper/model/library_model.rb +116 -0
- data/lib/big_keeper/model/operate_type.rb +27 -0
- data/lib/big_keeper/model/podfile_model.rb +33 -0
- data/lib/big_keeper/service/git_service.rb +210 -0
- data/lib/big_keeper/service/module_service.rb +159 -0
- data/lib/big_keeper/service/stash_service.rb +45 -0
- data/lib/big_keeper/util/bigkeeper_parser.rb +244 -0
- data/lib/big_keeper/util/cache_operator.rb +116 -0
- data/lib/big_keeper/util/code_operator.rb +37 -0
- data/lib/big_keeper/util/file_operator.rb +33 -0
- data/lib/big_keeper/util/git_operator.rb +221 -0
- data/lib/big_keeper/util/gitflow_operator.rb +51 -0
- data/lib/big_keeper/util/gradle_operator.rb +209 -0
- data/lib/big_keeper/util/info_plist_operator.rb +46 -0
- data/lib/big_keeper/util/leancloud_logger.rb +72 -0
- data/lib/big_keeper/util/list_generator.rb +101 -0
- data/lib/big_keeper/util/logger.rb +46 -0
- data/lib/big_keeper/util/pod_operator.rb +70 -0
- data/lib/big_keeper/util/podfile_detector.rb +111 -0
- data/lib/big_keeper/util/podfile_module.rb +63 -0
- data/lib/big_keeper/util/podfile_operator.rb +117 -0
- data/lib/big_keeper/util/verify_operator.rb +17 -0
- data/lib/big_keeper/util/xcode_operator.rb +15 -0
- data/lib/big_keeper/version.rb +3 -0
- data/lib/big_keeper.rb +71 -0
- data/resources/banner.png +0 -0
- data/resources/command.png +0 -0
- data/resources/keynote/big-keeper-readme-analyze.key +0 -0
- data/resources/keynote/big-keeper-readme-example.key +0 -0
- data/resources/keynote/big-keeper-readme-feature.key +0 -0
- data/resources/keynote/big-keeper-readme-release.key +0 -0
- data/resources/readme/big-keeper-readme.001.png +0 -0
- metadata +85 -2
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'big_keeper/util/file_operator'
|
2
|
+
require 'big_keeper/util/code_operator'
|
3
|
+
|
4
|
+
|
5
|
+
module BigKeeper
|
6
|
+
class LibraryModel
|
7
|
+
attr_accessor :name, :file_list, :header_file_list, :keyword_list, :spec_library
|
8
|
+
def initialize(name)
|
9
|
+
@name = name
|
10
|
+
@file_list = []
|
11
|
+
@header_file_list = []
|
12
|
+
@spec_library = []
|
13
|
+
@keyword_list = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_all_public_file(path)
|
17
|
+
all_header = FileOperator.find_all_header_file("#{path}/Pods/#{@name}")
|
18
|
+
for file_path in all_header do
|
19
|
+
@header_file_list[@header_file_list.size] = file_path
|
20
|
+
file_name = File.basename(file_path)
|
21
|
+
@keyword_list[@keyword_list.size] = file_name
|
22
|
+
in_note = false
|
23
|
+
File.foreach(file_path) { |line|
|
24
|
+
hash = Hash.new
|
25
|
+
hash["in_note"]=in_note
|
26
|
+
hash["line"]=line
|
27
|
+
OCCodeOperator.in_note_code(hash)
|
28
|
+
in_note = hash["in_note"]
|
29
|
+
line = hash["line"]
|
30
|
+
if line.empty?
|
31
|
+
next
|
32
|
+
end
|
33
|
+
if line.include?("@interface ")
|
34
|
+
line[0,line.index("@interface ")+11]=""
|
35
|
+
column = line.split(/:/)
|
36
|
+
if column.size > 1
|
37
|
+
class_name = column[0]
|
38
|
+
if class_name.include?("<")
|
39
|
+
class_name = class_name[0, class_name.index("<")]
|
40
|
+
end
|
41
|
+
class_name = class_name.strip
|
42
|
+
if (@keyword_list.include?(class_name+".h"))
|
43
|
+
@keyword_list.delete(class_name+".h")
|
44
|
+
end
|
45
|
+
@keyword_list[@keyword_list.size] = class_name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
# if @name == ""
|
51
|
+
# puts @keyword_list
|
52
|
+
# end
|
53
|
+
@file_list = FileOperator.find_all_code_file("#{path}/Pods/#{@name}")
|
54
|
+
end
|
55
|
+
|
56
|
+
def spec_dependece_library(library_keywords_hash)
|
57
|
+
if library_keywords_hash.include?(@name)
|
58
|
+
library_keywords_hash.delete(@name)
|
59
|
+
end
|
60
|
+
|
61
|
+
for file_path in @file_list do
|
62
|
+
# note for coding
|
63
|
+
in_note = false
|
64
|
+
File.foreach(file_path) { |line|
|
65
|
+
hash = Hash.new
|
66
|
+
hash["in_note"]=in_note
|
67
|
+
hash["line"]=line
|
68
|
+
OCCodeOperator.in_note_code(hash)
|
69
|
+
in_note = hash["in_note"]
|
70
|
+
line = hash["line"]
|
71
|
+
if line.empty?
|
72
|
+
next
|
73
|
+
end
|
74
|
+
library_keywords_hash.each {|library_name, keyword_list|
|
75
|
+
is_dependence = false
|
76
|
+
tip = ""
|
77
|
+
for keyword in keyword_list do
|
78
|
+
if line.include?(keyword)
|
79
|
+
last_char = '.'
|
80
|
+
last_index = line.index(keyword)-1
|
81
|
+
if last_index >= 0
|
82
|
+
last_char = line[last_index]
|
83
|
+
end
|
84
|
+
next_char = '.'
|
85
|
+
next_index = line.index(keyword)+keyword.size
|
86
|
+
if next_index < line.size
|
87
|
+
next_char = line[next_index]
|
88
|
+
end
|
89
|
+
if !(((next_char<='z'&&next_char>='a')||(next_char<='Z'&&next_char>='A')||(next_char<='9'&&next_char>='0')||next_char=='_')||((last_char<='z'&&last_char>='a')||(last_char<='Z'&&last_char>='A')||(last_char<='9'&&last_char>='0')||last_char=='_'))
|
90
|
+
if keyword.include?(".h") && line.include?("import") && line.include?("/"+keyword+">")
|
91
|
+
dependence_library_name = line[line.index("<")+1...line.index("/"+keyword+">")]
|
92
|
+
if dependence_library_name == library_name
|
93
|
+
tip = " [file]:"+File.basename(file_path)+" [line]: "+line.strip+" [keyword]: "+keyword
|
94
|
+
is_dependence = true
|
95
|
+
break
|
96
|
+
end
|
97
|
+
else
|
98
|
+
tip = " [file]:"+File.basename(file_path)+" [line]: "+line.strip+" [keyword]: "+keyword
|
99
|
+
is_dependence = true
|
100
|
+
break
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
if is_dependence
|
106
|
+
@spec_library[@spec_library.size] = library_name+tip
|
107
|
+
library_keywords_hash.delete(library_name)
|
108
|
+
end
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module BigKeeper
|
2
|
+
module OperateType
|
3
|
+
START = 1
|
4
|
+
UPDATE = 2
|
5
|
+
SWITCH = 3
|
6
|
+
|
7
|
+
def self.name(type)
|
8
|
+
if START == type
|
9
|
+
"start"
|
10
|
+
elsif UPDATE == type
|
11
|
+
"update"
|
12
|
+
elsif SWITCH == type
|
13
|
+
"switch"
|
14
|
+
else
|
15
|
+
name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ModuleOperateType
|
21
|
+
ADD = 1
|
22
|
+
DELETE = 2
|
23
|
+
FINISH = 3
|
24
|
+
PUBLISH = 4
|
25
|
+
RELEASE = 5
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module BigKeeper
|
3
|
+
|
4
|
+
class PodfileModel
|
5
|
+
attr_accessor :name, :git, :path, :configurations, :branch,:tag, :comment
|
6
|
+
def initialize(sentence)
|
7
|
+
if sentence.include?('#')
|
8
|
+
list = sentence.split('#')
|
9
|
+
@comment = list[1]
|
10
|
+
sentence = list[0]
|
11
|
+
end
|
12
|
+
|
13
|
+
sentence_slip_list = sentence.split(',')
|
14
|
+
return if sentence_slip_list.size.zero?
|
15
|
+
for piece in sentence_slip_list do
|
16
|
+
if /:git =>/ =~ piece
|
17
|
+
@git = $~.post_match.strip
|
18
|
+
elsif /:path =>/ =~ piece
|
19
|
+
@path = $~.post_match.strip
|
20
|
+
elsif /:configurations =>/ =~ piece
|
21
|
+
@configurations = $~.post_match.strip
|
22
|
+
elsif /:branch =>/ =~ piece
|
23
|
+
@branch = $~.post_match.strip
|
24
|
+
elsif /:tag =>/ =~ piece
|
25
|
+
@tag = $~.post_match.strip
|
26
|
+
elsif /pod /=~ piece
|
27
|
+
@name = $~.post_match.delete("'\n ")
|
28
|
+
end
|
29
|
+
# p %Q{model name:#{@name},git:#{@git},path:#{@path},config:#{@configurations},branch:#{@branch},tag:#{@tag},comment:#{@comment}}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,210 @@
|
|
1
|
+
require 'big_keeper/util/git_operator'
|
2
|
+
require 'big_keeper/util/gitflow_operator'
|
3
|
+
require 'big_keeper/model/gitflow_type'
|
4
|
+
require 'big_keeper/model/operate_type'
|
5
|
+
require 'big_keeper/util/logger'
|
6
|
+
|
7
|
+
module BigKeeper
|
8
|
+
# Operator for got
|
9
|
+
class GitService
|
10
|
+
def start(path, name, type)
|
11
|
+
git = GitOperator.new
|
12
|
+
|
13
|
+
branch_name = "#{GitflowType.name(type)}/#{name}"
|
14
|
+
if !git.has_remote_branch(path, branch_name) && !git.has_local_branch(path, branch_name)
|
15
|
+
|
16
|
+
verify_special_branch(path, 'master')
|
17
|
+
#verify_special_branch(path, 'develop')
|
18
|
+
|
19
|
+
GitflowOperator.new.verify_git_flow(path)
|
20
|
+
|
21
|
+
GitflowOperator.new.start(path, name, type)
|
22
|
+
git.push_to_remote(path, branch_name)
|
23
|
+
else
|
24
|
+
verify_checkout(path, branch_name)
|
25
|
+
|
26
|
+
if !git.has_remote_branch(path, branch_name)
|
27
|
+
git.push_to_remote(path, branch_name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def verify_checkout(path, branch_name)
|
33
|
+
Dir.chdir(path) do
|
34
|
+
cmd = "git checkout -b #{branch_name}"
|
35
|
+
if GitOperator.new.has_branch(path, branch_name)
|
36
|
+
cmd = "git checkout #{branch_name}"
|
37
|
+
end
|
38
|
+
IO.popen(cmd) do |io|
|
39
|
+
io.each do |line|
|
40
|
+
Logger.error("Checkout #{branch_name} failed.") if line.include? 'error'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def verify_checkout_pull(path, branch_name)
|
47
|
+
GitService.new.verify_checkout(path, branch_name)
|
48
|
+
GitService.new.pull(path, branch_name)
|
49
|
+
end
|
50
|
+
|
51
|
+
def verify_special_branch(path, name)
|
52
|
+
git = GitOperator.new
|
53
|
+
|
54
|
+
if git.has_remote_branch(path, name)
|
55
|
+
if git.has_local_branch(path, name)
|
56
|
+
if git.has_commits(path, name)
|
57
|
+
Logger.error(%Q('#{name}' has unpushed commits, you should fix it manually...))
|
58
|
+
end
|
59
|
+
pull(path, name)
|
60
|
+
else
|
61
|
+
git.checkout(path, name)
|
62
|
+
end
|
63
|
+
else
|
64
|
+
verify_checkout(path, name)
|
65
|
+
git.push_to_remote(path, name)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def verify_home_branch(path, branch_name, type)
|
70
|
+
Logger.highlight('Sync local branchs from remote, waiting...')
|
71
|
+
git = GitOperator.new
|
72
|
+
|
73
|
+
git.fetch(path)
|
74
|
+
|
75
|
+
if OperateType::START == type
|
76
|
+
if git.current_branch(path) == branch_name
|
77
|
+
Logger.error(%(Current branch is '#{branch_name}' already. Use 'update' please))
|
78
|
+
end
|
79
|
+
if git.has_branch(path, branch_name)
|
80
|
+
Logger.error(%(Branch '#{branch_name}' already exists. Use 'switch' please))
|
81
|
+
end
|
82
|
+
elsif OperateType::SWITCH == type
|
83
|
+
if !git.has_branch(path, branch_name)
|
84
|
+
Logger.error(%(Can't find a branch named '#{branch_name}'. Use 'start' please))
|
85
|
+
end
|
86
|
+
if git.current_branch(path) == branch_name
|
87
|
+
Logger.error(%(Current branch is '#{branch_name}' already. Use 'update' please))
|
88
|
+
end
|
89
|
+
elsif OperateType::UPDATE == type
|
90
|
+
if !git.has_branch(path, branch_name)
|
91
|
+
Logger.error(%(Can't find a branch named '#{branch_name}'. Use 'start' please))
|
92
|
+
end
|
93
|
+
if git.current_branch(path) != branch_name
|
94
|
+
Logger.error(%(Current branch is not '#{branch_name}'. Use 'switch' please))
|
95
|
+
end
|
96
|
+
else
|
97
|
+
Logger.error(%(Not a valid command for '#{branch_name}'.))
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def current_branch_type(path)
|
102
|
+
branch_name = GitOperator.new.current_branch(path)
|
103
|
+
if branch_name =~ /^feature\/S*/
|
104
|
+
GitflowType::FEATURE
|
105
|
+
elsif branch_name =~ /^hotfix\/S*/
|
106
|
+
GitflowType::HOTFIX
|
107
|
+
elsif branch_name =~ /^release\/S*/
|
108
|
+
GitflowType::RELEASE
|
109
|
+
else
|
110
|
+
GitflowType::FEATURE
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def branchs_with_type(path, type)
|
115
|
+
branchs = []
|
116
|
+
Dir.chdir(path) do
|
117
|
+
IO.popen('git branch -r') do | io |
|
118
|
+
io.each do | line |
|
119
|
+
branchs << line.gsub(/\s/, '') if line =~ /[\s\S]*#{GitflowType.name(type)}*/
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
branchs
|
124
|
+
end
|
125
|
+
|
126
|
+
def pull(path, branch_name)
|
127
|
+
git = GitOperator.new
|
128
|
+
current_branch_name = git.current_branch(path)
|
129
|
+
if current_branch_name == branch_name
|
130
|
+
git.pull(path)
|
131
|
+
else
|
132
|
+
git.checkout(path, branch_name)
|
133
|
+
git.pull(path)
|
134
|
+
git.checkout(path, current_branch_name)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def verify_del(path, branch_name, name, type)
|
139
|
+
git = GitOperator.new
|
140
|
+
|
141
|
+
if git.has_local_branch(path, branch_name)
|
142
|
+
Logger.highlight("Delete local branch '#{branch_name}' for '#{name}'...")
|
143
|
+
|
144
|
+
if git.current_branch(path) == branch_name
|
145
|
+
git.discard(path)
|
146
|
+
git.checkout(path, GitflowType.base_branch(type))
|
147
|
+
end
|
148
|
+
git.del_local(path, branch_name)
|
149
|
+
end
|
150
|
+
|
151
|
+
if git.has_remote_branch(path, branch_name)
|
152
|
+
Logger.highlight("Delete remote branch '#{branch_name}' for '#{name}'...")
|
153
|
+
git.del_remote(path, branch_name)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def verify_push(path, comment, branch_name, name)
|
158
|
+
git = GitOperator.new
|
159
|
+
if git.has_changes(path) || git.has_commits(path, branch_name)
|
160
|
+
|
161
|
+
git.commit(path, comment) if git.has_changes(path)
|
162
|
+
|
163
|
+
if git.has_remote_branch(path, branch_name)
|
164
|
+
Dir.chdir(path) do
|
165
|
+
`git push`
|
166
|
+
end
|
167
|
+
else
|
168
|
+
git.push_to_remote(path, branch_name)
|
169
|
+
end
|
170
|
+
|
171
|
+
GitOperator.new.check_push_success(path, branch_name, "origin/#{branch_name}")
|
172
|
+
else
|
173
|
+
Logger.default("Nothing to push for '#{name}'.")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def verify_rebase(path, branch_name, name)
|
178
|
+
|
179
|
+
# pull rebased branch
|
180
|
+
pull(path, branch_name)
|
181
|
+
|
182
|
+
Dir.chdir(path) do
|
183
|
+
IO.popen("git rebase #{branch_name} --ignore-whitespace") do |io|
|
184
|
+
unless io.gets
|
185
|
+
Logger.error("#{name} is already in a rebase-apply, Please:\n"\
|
186
|
+
" 1.Resolve it;\n"\
|
187
|
+
" 2.Commit the changes;\n"\
|
188
|
+
" 3.Push to remote;\n"\
|
189
|
+
" 4.Create a MR;\n"\
|
190
|
+
" 5.Run 'finish' again.")
|
191
|
+
end
|
192
|
+
io.each do |line|
|
193
|
+
next unless line.include? 'Merge conflict'
|
194
|
+
Logger.error("Merge conflict in #{name}, Please:\n"\
|
195
|
+
" 1.Resolve it;\n"\
|
196
|
+
" 2.Commit the changes;\n"\
|
197
|
+
" 3.Push to remote;\n"\
|
198
|
+
" 4.Create a MR;\n"\
|
199
|
+
" 5.Run 'finish' again.")
|
200
|
+
end
|
201
|
+
end
|
202
|
+
if GitOperator.new.current_branch(path) != 'develop' && GitOperator.new.current_branch(path) != 'master'
|
203
|
+
`git push -f`
|
204
|
+
else
|
205
|
+
Logger.error("You should not push 'master' or 'develop'")
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
require 'big_keeper/service/git_service'
|
2
|
+
|
3
|
+
require 'big_keeper/util/logger'
|
4
|
+
require 'big_keeper/util/cache_operator'
|
5
|
+
|
6
|
+
module BigKeeper
|
7
|
+
# Operator for got
|
8
|
+
class ModuleService
|
9
|
+
|
10
|
+
def verify_module(path, user, module_name, home_branch_name, type)
|
11
|
+
name = home_branch_name.gsub(/#{GitflowType.name(type)}\//, '')
|
12
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
13
|
+
|
14
|
+
git = GitOperator.new
|
15
|
+
if !File.exist? module_full_path
|
16
|
+
Logger.default("No local repository for module '#{module_name}', clone it...")
|
17
|
+
module_git = BigkeeperParser.module_git(module_name)
|
18
|
+
git.clone(File.expand_path("#{module_full_path}/../"), module_git)
|
19
|
+
end
|
20
|
+
|
21
|
+
current_branch_name = git.current_branch(module_full_path)
|
22
|
+
if current_branch_name != home_branch_name
|
23
|
+
# stash current branch
|
24
|
+
StashService.new.stash(module_full_path, current_branch_name, module_name)
|
25
|
+
|
26
|
+
GitService.new.start(module_full_path, name, type)
|
27
|
+
|
28
|
+
StashService.new.pop_stash(module_full_path, home_branch_name, module_name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def push(path, user, module_name, home_branch_name, type, comment)
|
33
|
+
Logger.highlight("Push branch '#{home_branch_name}' for module '#{module_name}'...")
|
34
|
+
|
35
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
36
|
+
|
37
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
38
|
+
GitService.new.verify_push(module_full_path, comment, home_branch_name, module_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def rebase(path, user, module_name, home_branch_name, type)
|
42
|
+
Logger.highlight("Rebase '#{GitflowType.base_branch(type)}' "\
|
43
|
+
"to branch '#{home_branch_name}' for module "\
|
44
|
+
"'#{module_name}'...")
|
45
|
+
|
46
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
47
|
+
|
48
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
49
|
+
|
50
|
+
Logger.error("You have some changes in branch "\
|
51
|
+
"'#{home_branch_name}' for module '#{module_name}'. "\
|
52
|
+
"Use 'push' first please") if GitOperator.new.has_changes(module_full_path)
|
53
|
+
|
54
|
+
GitService.new.verify_rebase(module_full_path, GitflowType.base_branch(type), module_name)
|
55
|
+
end
|
56
|
+
|
57
|
+
def pull(path, user, module_name, home_branch_name, type)
|
58
|
+
Logger.highlight("Pull branch '#{home_branch_name}' for module '#{module_name}'...")
|
59
|
+
|
60
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
61
|
+
|
62
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
63
|
+
GitOperator.new.pull(module_full_path)
|
64
|
+
end
|
65
|
+
|
66
|
+
def switch_to(path, user, module_name, home_branch_name, type)
|
67
|
+
Logger.highlight("Switch to branch '#{home_branch_name}' for module '#{module_name}'...")
|
68
|
+
|
69
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
70
|
+
end
|
71
|
+
|
72
|
+
def pre_publish(path, user, module_name, home_branch_name, type)
|
73
|
+
Logger.highlight("Prepare to publish branch '#{home_branch_name}' for module '#{module_name}'...")
|
74
|
+
|
75
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
76
|
+
|
77
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
78
|
+
GitService.new.verify_push(module_full_path, "prepare to rebase '#{GitflowType.base_branch(type)}'", home_branch_name, module_name)
|
79
|
+
GitService.new.verify_rebase(module_full_path, GitflowType.base_branch(type), module_name)
|
80
|
+
end
|
81
|
+
|
82
|
+
def publish(path, user, module_name, home_branch_name, type)
|
83
|
+
Logger.highlight("Publish branch '#{home_branch_name}' for module '#{module_name}'...")
|
84
|
+
|
85
|
+
DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::PUBLISH)
|
86
|
+
|
87
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
88
|
+
GitService.new.verify_push(module_full_path, "publish branch #{home_branch_name}", home_branch_name, module_name)
|
89
|
+
|
90
|
+
`open #{BigkeeperParser.module_pulls(module_name)}`
|
91
|
+
|
92
|
+
ModuleCacheOperator.new(path).del_git_module(module_name)
|
93
|
+
end
|
94
|
+
|
95
|
+
def finish(path, user, module_name, home_branch_name, type)
|
96
|
+
Logger.highlight("Finish branch '#{home_branch_name}' for module '#{module_name}'...")
|
97
|
+
|
98
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
99
|
+
|
100
|
+
DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::FINISH)
|
101
|
+
|
102
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
103
|
+
GitService.new.verify_push(module_full_path, "finish branch #{home_branch_name}", home_branch_name, module_name)
|
104
|
+
|
105
|
+
ModuleCacheOperator.new(path).add_git_module(module_name)
|
106
|
+
ModuleCacheOperator.new(path).del_path_module(module_name)
|
107
|
+
end
|
108
|
+
|
109
|
+
def add(path, user, module_name, name, type)
|
110
|
+
home_branch_name = "#{GitflowType.name(type)}/#{name}"
|
111
|
+
Logger.highlight("Add branch '#{home_branch_name}' for module '#{module_name}'...")
|
112
|
+
|
113
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
114
|
+
|
115
|
+
DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::ADD)
|
116
|
+
|
117
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
118
|
+
GitService.new.verify_push(module_full_path, "init #{GitflowType.name(type)} #{name}", home_branch_name, module_name)
|
119
|
+
|
120
|
+
ModuleCacheOperator.new(path).add_path_module(module_name)
|
121
|
+
end
|
122
|
+
|
123
|
+
def del(path, user, module_name, name, type)
|
124
|
+
home_branch_name = "#{GitflowType.name(type)}/#{name}"
|
125
|
+
|
126
|
+
Logger.highlight("Delete branch '#{home_branch_name}' for module '#{module_name}'...")
|
127
|
+
|
128
|
+
module_git = BigkeeperParser.module_git(module_name)
|
129
|
+
DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::DELETE)
|
130
|
+
|
131
|
+
# Stash module current branch
|
132
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
133
|
+
current_branch_name = GitOperator.new.current_branch(module_full_path)
|
134
|
+
StashService.new.stash(module_full_path, current_branch_name, module_name)
|
135
|
+
GitOperator.new.checkout(module_full_path, GitflowType.base_branch(type))
|
136
|
+
|
137
|
+
ModuleCacheOperator.new(path).del_path_module(module_name)
|
138
|
+
end
|
139
|
+
|
140
|
+
def module_info(module_path, home_branch_name, user, type, module_name, version)
|
141
|
+
result_dic = {}
|
142
|
+
matched_branches = []
|
143
|
+
branches = GitService.new.branchs_with_type(module_path, type)
|
144
|
+
if version == 'all versions'
|
145
|
+
matched_branches = branches
|
146
|
+
else
|
147
|
+
branches.each do | branch |
|
148
|
+
matched_branches << branch if branch.include?(version)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
result_dic[:module_name] = module_name
|
152
|
+
result_dic[:current_branch] = GitOperator.new.current_branch(module_path)
|
153
|
+
result_dic[:branches] = matched_branches
|
154
|
+
result_dic
|
155
|
+
end
|
156
|
+
|
157
|
+
private :verify_module
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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)
|
26
|
+
# Stash modules
|
27
|
+
Logger.highlight('Stash for current workspace...')
|
28
|
+
|
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
|
+
if branch_name != new_branch_name
|
34
|
+
stash(module_path, branch_name, module_name)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Stash home
|
39
|
+
branch_name = GitOperator.new.current_branch(path)
|
40
|
+
if branch_name != new_branch_name
|
41
|
+
stash(path, branch_name, 'Home')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|