kookeeper 3.0.1 → 3.0.4

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 (89) 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/bin/big +14 -0
  14. data/bin/koo +14 -0
  15. data/bin/setup +8 -0
  16. data/docs/en-US/FEATURE.md +0 -0
  17. data/docs/en-US/README.md +54 -0
  18. data/docs/zh-CN/BIGKEEPER_FILE.md +84 -0
  19. data/docs/zh-CN/FEATURE&HOTFIX.md +88 -0
  20. data/docs/zh-CN/IMAGE.md +0 -0
  21. data/docs/zh-CN/PODFILE.md +43 -0
  22. data/docs/zh-CN/README.md +113 -0
  23. data/docs/zh-CN/RECOMMEND.md +22 -0
  24. data/docs/zh-CN/RELEASE.md +60 -0
  25. data/docs/zh-CN/SPEC.md +39 -0
  26. data/lib/big_keeper/command/feature&hotfix/delete.rb +40 -0
  27. data/lib/big_keeper/command/feature&hotfix/finish.rb +54 -0
  28. data/lib/big_keeper/command/feature&hotfix/list.rb +63 -0
  29. data/lib/big_keeper/command/feature&hotfix/publish.rb +56 -0
  30. data/lib/big_keeper/command/feature&hotfix/pull.rb +26 -0
  31. data/lib/big_keeper/command/feature&hotfix/push.rb +27 -0
  32. data/lib/big_keeper/command/feature&hotfix/rebase.rb +32 -0
  33. data/lib/big_keeper/command/feature&hotfix/start.rb +75 -0
  34. data/lib/big_keeper/command/feature&hotfix/switch.rb +46 -0
  35. data/lib/big_keeper/command/feature&hotfix/update.rb +66 -0
  36. data/lib/big_keeper/command/feature&hotfix.rb +167 -0
  37. data/lib/big_keeper/command/image/image.rb +0 -0
  38. data/lib/big_keeper/command/image.rb +28 -0
  39. data/lib/big_keeper/command/pod/podfile.rb +69 -0
  40. data/lib/big_keeper/command/pod.rb +42 -0
  41. data/lib/big_keeper/command/release/home.rb +91 -0
  42. data/lib/big_keeper/command/release/module.rb +61 -0
  43. data/lib/big_keeper/command/release.rb +75 -0
  44. data/lib/big_keeper/command/spec/add.rb +9 -0
  45. data/lib/big_keeper/command/spec/analyze.rb +88 -0
  46. data/lib/big_keeper/command/spec/delete.rb +9 -0
  47. data/lib/big_keeper/command/spec/list.rb +19 -0
  48. data/lib/big_keeper/command/spec/search.rb +9 -0
  49. data/lib/big_keeper/command/spec/sync.rb +12 -0
  50. data/lib/big_keeper/command/spec.rb +78 -0
  51. data/lib/big_keeper/dependency/dep_gradle_operator.rb +56 -0
  52. data/lib/big_keeper/dependency/dep_operator.rb +32 -0
  53. data/lib/big_keeper/dependency/dep_pod_operator.rb +130 -0
  54. data/lib/big_keeper/dependency/dep_service.rb +14 -0
  55. data/lib/big_keeper/dependency/dep_type.rb +33 -0
  56. data/lib/big_keeper/model/gitflow_type.rb +43 -0
  57. data/lib/big_keeper/model/library_model.rb +116 -0
  58. data/lib/big_keeper/model/operate_type.rb +27 -0
  59. data/lib/big_keeper/model/podfile_model.rb +33 -0
  60. data/lib/big_keeper/service/git_service.rb +233 -0
  61. data/lib/big_keeper/service/module_service.rb +159 -0
  62. data/lib/big_keeper/service/stash_service.rb +45 -0
  63. data/lib/big_keeper/util/bigkeeper_parser.rb +244 -0
  64. data/lib/big_keeper/util/cache_operator.rb +116 -0
  65. data/lib/big_keeper/util/code_operator.rb +37 -0
  66. data/lib/big_keeper/util/file_operator.rb +33 -0
  67. data/lib/big_keeper/util/git_operator.rb +221 -0
  68. data/lib/big_keeper/util/gitflow_operator.rb +51 -0
  69. data/lib/big_keeper/util/gradle_operator.rb +209 -0
  70. data/lib/big_keeper/util/info_plist_operator.rb +46 -0
  71. data/lib/big_keeper/util/leancloud_logger.rb +72 -0
  72. data/lib/big_keeper/util/list_generator.rb +101 -0
  73. data/lib/big_keeper/util/logger.rb +46 -0
  74. data/lib/big_keeper/util/pod_operator.rb +70 -0
  75. data/lib/big_keeper/util/podfile_detector.rb +111 -0
  76. data/lib/big_keeper/util/podfile_module.rb +63 -0
  77. data/lib/big_keeper/util/podfile_operator.rb +117 -0
  78. data/lib/big_keeper/util/verify_operator.rb +17 -0
  79. data/lib/big_keeper/util/xcode_operator.rb +15 -0
  80. data/lib/big_keeper/version.rb +3 -0
  81. data/lib/big_keeper.rb +71 -0
  82. data/resources/banner.png +0 -0
  83. data/resources/command.png +0 -0
  84. data/resources/keynote/big-keeper-readme-analyze.key +0 -0
  85. data/resources/keynote/big-keeper-readme-example.key +0 -0
  86. data/resources/keynote/big-keeper-readme-feature.key +0 -0
  87. data/resources/keynote/big-keeper-readme-release.key +0 -0
  88. data/resources/readme/big-keeper-readme.001.png +0 -0
  89. metadata +92 -3
@@ -0,0 +1,14 @@
1
+ require 'big_keeper/util/git_operator'
2
+ require 'big_keeper/model/gitflow_type'
3
+ require 'big_keeper/model/operate_type'
4
+ require 'big_keeper/util/logger'
5
+ require 'big_keeper/dependency/dep_type'
6
+
7
+ module BigKeeper
8
+ # Operator for podfile
9
+ class DepService
10
+ def self.dep_operator(path, user)
11
+ DepType.operator(path, user)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ require 'big_keeper/dependency/dep_operator'
2
+ require 'big_keeper/dependency/dep_pod_operator'
3
+ require 'big_keeper/dependency/dep_gradle_operator'
4
+ require 'big_keeper/util/file_operator'
5
+
6
+ module BigKeeper
7
+ module DepType
8
+ NONE = 0
9
+ COCOAPODS = 1
10
+ GRADLE = 2
11
+
12
+ def self.type(path)
13
+ if FileOperator.definitely_exists?("#{path}/Podfile")
14
+ COCOAPODS
15
+ elsif FileOperator.definitely_exists?("#{path}/build.gradle")
16
+ GRADLE
17
+ else
18
+ NONE
19
+ end
20
+ end
21
+
22
+ def self.operator(path, user)
23
+ operator_type = type(path)
24
+ if COCOAPODS == operator_type
25
+ DepPodOperator.new(path, user)
26
+ elsif GRADLE == operator_type
27
+ DepGradleOperator.new(path, user)
28
+ else
29
+ DepOperator.new(path, user)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,43 @@
1
+ module BigKeeper
2
+ module GitflowType
3
+ FEATURE = 1
4
+ HOTFIX = 2
5
+ RELEASE = 3
6
+
7
+ def self.name(type)
8
+ if FEATURE == type
9
+ "feature"
10
+ elsif HOTFIX == type
11
+ "hotfix"
12
+ elsif RELEASE == type
13
+ "release"
14
+ else
15
+ "feature"
16
+ end
17
+ end
18
+
19
+ def self.command(type)
20
+ if FEATURE == type
21
+ :feature
22
+ elsif HOTFIX == type
23
+ :hotfix
24
+ elsif RELEASE == type
25
+ :release
26
+ else
27
+ :feature
28
+ end
29
+ end
30
+
31
+ def self.base_branch(type)
32
+ if FEATURE == type
33
+ "develop"
34
+ elsif HOTFIX == type
35
+ "master"
36
+ elsif RELEASE == type
37
+ "develop"
38
+ else
39
+ "master"
40
+ end
41
+ end
42
+ end
43
+ end
@@ -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,233 @@
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
+
11
+ def startHome(path, name, type)
12
+ git = GitOperator.new
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
+
33
+ def start(path, name, type)
34
+ git = GitOperator.new
35
+
36
+ branch_name = "#{GitflowType.name(type)}/#{name}"
37
+ if !git.has_remote_branch(path, branch_name) && !git.has_local_branch(path, branch_name)
38
+
39
+ verify_special_branch(path, 'master')
40
+ #verify_special_branch(path, 'develop')
41
+
42
+ GitflowOperator.new.verify_git_flow(path)
43
+
44
+ GitflowOperator.new.start(path, name, type)
45
+ git.push_to_remote(path, branch_name)
46
+ else
47
+ verify_checkout(path, branch_name)
48
+
49
+ if !git.has_remote_branch(path, branch_name)
50
+ git.push_to_remote(path, branch_name)
51
+ end
52
+ end
53
+ end
54
+
55
+ def verify_checkout(path, branch_name)
56
+ Dir.chdir(path) do
57
+ cmd = "git checkout -b #{branch_name}"
58
+ if GitOperator.new.has_branch(path, branch_name)
59
+ cmd = "git checkout #{branch_name}"
60
+ end
61
+ IO.popen(cmd) do |io|
62
+ io.each do |line|
63
+ Logger.error("Checkout #{branch_name} failed.") if line.include? 'error'
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ def verify_checkout_pull(path, branch_name)
70
+ GitService.new.verify_checkout(path, branch_name)
71
+ GitService.new.pull(path, branch_name)
72
+ end
73
+
74
+ def verify_special_branch(path, name)
75
+ git = GitOperator.new
76
+
77
+ if git.has_remote_branch(path, name)
78
+ if git.has_local_branch(path, name)
79
+ if git.has_commits(path, name)
80
+ Logger.error(%Q('#{name}' has unpushed commits, you should fix it manually...))
81
+ end
82
+ pull(path, name)
83
+ else
84
+ git.checkout(path, name)
85
+ end
86
+ else
87
+ verify_checkout(path, name)
88
+ git.push_to_remote(path, name)
89
+ end
90
+ end
91
+
92
+ def verify_home_branch(path, branch_name, type)
93
+ Logger.highlight('Sync local branchs from remote, waiting...')
94
+ git = GitOperator.new
95
+
96
+ git.fetch(path)
97
+
98
+ if OperateType::START == type
99
+ if git.current_branch(path) == branch_name
100
+ Logger.error(%(Current branch is '#{branch_name}' already. Use 'update' please))
101
+ end
102
+ if git.has_branch(path, branch_name)
103
+ Logger.error(%(Branch '#{branch_name}' already exists. Use 'switch' please))
104
+ end
105
+ elsif OperateType::SWITCH == type
106
+ if !git.has_branch(path, branch_name)
107
+ Logger.error(%(Can't find a branch named '#{branch_name}'. Use 'start' please))
108
+ end
109
+ if git.current_branch(path) == branch_name
110
+ Logger.error(%(Current branch is '#{branch_name}' already. Use 'update' please))
111
+ end
112
+ elsif OperateType::UPDATE == type
113
+ if !git.has_branch(path, branch_name)
114
+ Logger.error(%(Can't find a branch named '#{branch_name}'. Use 'start' please))
115
+ end
116
+ if git.current_branch(path) != branch_name
117
+ Logger.error(%(Current branch is not '#{branch_name}'. Use 'switch' please))
118
+ end
119
+ else
120
+ Logger.error(%(Not a valid command for '#{branch_name}'.))
121
+ end
122
+ end
123
+
124
+ def current_branch_type(path)
125
+ branch_name = GitOperator.new.current_branch(path)
126
+ if branch_name =~ /^feature\/S*/
127
+ GitflowType::FEATURE
128
+ elsif branch_name =~ /^hotfix\/S*/
129
+ GitflowType::HOTFIX
130
+ elsif branch_name =~ /^release\/S*/
131
+ GitflowType::RELEASE
132
+ else
133
+ GitflowType::FEATURE
134
+ end
135
+ end
136
+
137
+ def branchs_with_type(path, type)
138
+ branchs = []
139
+ Dir.chdir(path) do
140
+ IO.popen('git branch -r') do | io |
141
+ io.each do | line |
142
+ branchs << line.gsub(/\s/, '') if line =~ /[\s\S]*#{GitflowType.name(type)}*/
143
+ end
144
+ end
145
+ end
146
+ branchs
147
+ end
148
+
149
+ def pull(path, branch_name)
150
+ git = GitOperator.new
151
+ current_branch_name = git.current_branch(path)
152
+ if current_branch_name == branch_name
153
+ git.pull(path)
154
+ else
155
+ git.checkout(path, branch_name)
156
+ git.pull(path)
157
+ git.checkout(path, current_branch_name)
158
+ end
159
+ end
160
+
161
+ def verify_del(path, branch_name, name, type)
162
+ git = GitOperator.new
163
+
164
+ if git.has_local_branch(path, branch_name)
165
+ Logger.highlight("Delete local branch '#{branch_name}' for '#{name}'...")
166
+
167
+ if git.current_branch(path) == branch_name
168
+ git.discard(path)
169
+ git.checkout(path, GitflowType.base_branch(type))
170
+ end
171
+ git.del_local(path, branch_name)
172
+ end
173
+
174
+ if git.has_remote_branch(path, branch_name)
175
+ Logger.highlight("Delete remote branch '#{branch_name}' for '#{name}'...")
176
+ git.del_remote(path, branch_name)
177
+ end
178
+ end
179
+
180
+ def verify_push(path, comment, branch_name, name)
181
+ git = GitOperator.new
182
+ if git.has_changes(path) || git.has_commits(path, branch_name)
183
+
184
+ git.commit(path, comment) if git.has_changes(path)
185
+
186
+ if git.has_remote_branch(path, branch_name)
187
+ Dir.chdir(path) do
188
+ `git push`
189
+ end
190
+ else
191
+ git.push_to_remote(path, branch_name)
192
+ end
193
+
194
+ GitOperator.new.check_push_success(path, branch_name, "origin/#{branch_name}")
195
+ else
196
+ Logger.default("Nothing to push for '#{name}'.")
197
+ end
198
+ end
199
+
200
+ def verify_rebase(path, branch_name, name)
201
+
202
+ # pull rebased branch
203
+ pull(path, branch_name)
204
+
205
+ Dir.chdir(path) do
206
+ IO.popen("git rebase #{branch_name} --ignore-whitespace") do |io|
207
+ unless io.gets
208
+ Logger.error("#{name} is already in a rebase-apply, Please:\n"\
209
+ " 1.Resolve it;\n"\
210
+ " 2.Commit the changes;\n"\
211
+ " 3.Push to remote;\n"\
212
+ " 4.Create a MR;\n"\
213
+ " 5.Run 'finish' again.")
214
+ end
215
+ io.each do |line|
216
+ next unless line.include? 'Merge conflict'
217
+ Logger.error("Merge conflict in #{name}, Please:\n"\
218
+ " 1.Resolve it;\n"\
219
+ " 2.Commit the changes;\n"\
220
+ " 3.Push to remote;\n"\
221
+ " 4.Create a MR;\n"\
222
+ " 5.Run 'finish' again.")
223
+ end
224
+ end
225
+ if GitOperator.new.current_branch(path) != 'develop' && GitOperator.new.current_branch(path) != 'master'
226
+ `git push -f`
227
+ else
228
+ Logger.error("You should not push 'master' or 'develop'")
229
+ end
230
+ end
231
+ end
232
+ end
233
+ 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