big_keeper 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +79 -20
- data/bin/{big-keeper → bigkeeper} +0 -0
- data/docs/en-US/README.md +50 -0
- data/docs/zh-CN/BIGKEEPER_FILE.md +2 -2
- data/docs/zh-CN/FEATURE&HOTFIX.md +121 -0
- data/docs/zh-CN/PODFILE.md +43 -0
- data/docs/zh-CN/README.md +33 -15
- data/docs/zh-CN/RECOMMEND.md +22 -0
- data/docs/zh-CN/RELEASE.md +8 -5
- data/lib/big_keeper/command/feature&hotfix/delete.rb +33 -0
- data/lib/big_keeper/command/feature&hotfix/{feature_finish.rb → finish.rb} +13 -12
- data/lib/big_keeper/command/feature&hotfix/{feature_pull.rb → pull.rb} +4 -4
- data/lib/big_keeper/command/feature&hotfix/{feature_push.rb → push.rb} +4 -8
- data/lib/big_keeper/command/feature&hotfix/{feature_start.rb → start.rb} +7 -7
- data/lib/big_keeper/command/feature&hotfix/{feature_switch.rb → switch.rb} +6 -6
- data/lib/big_keeper/command/feature&hotfix/{feature_update.rb → update.rb} +7 -7
- data/lib/big_keeper/command/release/{release_home.rb → home.rb} +4 -4
- data/lib/big_keeper/command/release/module.rb +106 -0
- data/lib/big_keeper/model/gitflow_type.rb +13 -1
- data/lib/big_keeper/service/git_service.rb +84 -40
- data/lib/big_keeper/service/module_service.rb +52 -62
- data/lib/big_keeper/util/bigkeeper_parser.rb +19 -3
- data/lib/big_keeper/util/git_operator.rb +19 -12
- data/lib/big_keeper/version.rb +1 -1
- data/lib/big_keeper.rb +131 -25
- data/resources/banner.png +0 -0
- data/resources/keynote/big-keeper-readme-example.key +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.001.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.002.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.003.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.004.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.005.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.006.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.007.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.008.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.009.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.010.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.011.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.012.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.013.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.014.jpeg +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.008.png +0 -0
- data/resources/readme/big-keeper-readme.009.png +0 -0
- data/resources/readme/big-keeper-readme.010.png +0 -0
- data/resources/readme/big-keeper-readme.011.png +0 -0
- data/resources/readme/big-keeper-readme.012.png +0 -0
- metadata +40 -17
- data/docs/zh-CN/FEATURE.md +0 -88
- data/lib/big_keeper/command/release/release_module.rb +0 -86
- data/lib/big_keeper/command/release/release_module.sh +0 -44
- data/resources/readme/big-keeper-readme.008.jpeg +0 -0
- data/resources/readme/big-keeper-readme.009.jpeg +0 -0
- data/resources/readme/big-keeper-readme.010.jpeg +0 -0
@@ -2,23 +2,19 @@ require 'big_keeper/util/logger'
|
|
2
2
|
|
3
3
|
module BigKeeper
|
4
4
|
|
5
|
-
def self.
|
5
|
+
def self.push(path, user, comment, type)
|
6
6
|
begin
|
7
7
|
# Parse Bigkeeper file
|
8
8
|
BigkeeperParser.parse("#{path}/Bigkeeper")
|
9
|
-
|
10
9
|
branch_name = GitOperator.new.current_branch(path)
|
11
|
-
|
10
|
+
|
11
|
+
Logger.error("Not a #{GitflowType.name(type)} branch, exit.") unless branch_name.include? GitflowType.name(type)
|
12
12
|
|
13
13
|
modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
|
14
14
|
BigkeeperParser.module_names, ModuleType::PATH)
|
15
15
|
|
16
16
|
modules.each do |module_name|
|
17
|
-
|
18
|
-
module_branch_name = GitOperator.new.current_branch(module_full_path)
|
19
|
-
|
20
|
-
Logger.highlight("Push branch '#{branch_name}' for module '#{module_name}'...")
|
21
|
-
GitService.new.verify_push(path, comment, module_branch_name, module_name)
|
17
|
+
ModuleService.new.push(path, user, module_name, branch_name, type, comment)
|
22
18
|
end
|
23
19
|
|
24
20
|
Logger.highlight("Push branch '#{branch_name}' for 'Home'...")
|
@@ -13,16 +13,16 @@ require 'big_keeper/service/module_service'
|
|
13
13
|
|
14
14
|
|
15
15
|
module BigKeeper
|
16
|
-
def self.
|
16
|
+
def self.start(path, version, user, name, modules, type)
|
17
17
|
begin
|
18
18
|
# Parse Bigkeeper file
|
19
19
|
BigkeeperParser.parse("#{path}/Bigkeeper")
|
20
20
|
|
21
21
|
version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
|
22
|
-
|
23
|
-
branch_name = "#{GitflowType.name(
|
22
|
+
full_name = "#{version}_#{user}_#{name}"
|
23
|
+
branch_name = "#{GitflowType.name(type)}/#{full_name}"
|
24
24
|
|
25
|
-
GitService.new.
|
25
|
+
GitService.new.verify_home_branch(path, branch_name, OperateType::START)
|
26
26
|
|
27
27
|
stash_modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
|
28
28
|
BigkeeperParser.module_names, ModuleType::PATH)
|
@@ -41,18 +41,18 @@ module BigKeeper
|
|
41
41
|
|
42
42
|
Logger.highlight("Add branch '#{branch_name}' for 'Home'...")
|
43
43
|
# Start home feature
|
44
|
-
GitService.new.start(path,
|
44
|
+
GitService.new.start(path, full_name, type)
|
45
45
|
|
46
46
|
# Modify podfile as path and Start modules feature
|
47
47
|
modules.each do |module_name|
|
48
|
-
ModuleService.new.add(path, user, module_name,
|
48
|
+
ModuleService.new.add(path, user, module_name, full_name, type)
|
49
49
|
end
|
50
50
|
|
51
51
|
# pod install
|
52
52
|
PodOperator.pod_install(path)
|
53
53
|
|
54
54
|
# Push home changes to remote
|
55
|
-
GitService.new.verify_push(path, "init #{GitflowType.name(
|
55
|
+
GitService.new.verify_push(path, "init #{GitflowType.name(type)} #{full_name}", branch_name, 'Home')
|
56
56
|
|
57
57
|
# Open home workspace
|
58
58
|
`open #{path}/*.xcworkspace`
|
@@ -4,16 +4,16 @@ require 'big_keeper/util/logger'
|
|
4
4
|
require 'big_keeper/util/pod_operator'
|
5
5
|
|
6
6
|
module BigKeeper
|
7
|
-
def self.
|
7
|
+
def self.switch_to(path, version, user, name, type)
|
8
8
|
begin
|
9
9
|
# Parse Bigkeeper file
|
10
10
|
BigkeeperParser.parse("#{path}/Bigkeeper")
|
11
11
|
|
12
12
|
version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
|
13
|
-
|
14
|
-
branch_name = "#{GitflowType.name(
|
13
|
+
full_name = "#{version}_#{user}_#{name}"
|
14
|
+
branch_name = "#{GitflowType.name(type)}/#{full_name}"
|
15
15
|
|
16
|
-
GitService.new.
|
16
|
+
GitService.new.verify_home_branch(path, branch_name, OperateType::SWITCH)
|
17
17
|
|
18
18
|
stash_modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
|
19
19
|
BigkeeperParser.module_names, ModuleType::PATH)
|
@@ -22,7 +22,7 @@ module BigKeeper
|
|
22
22
|
StashService.new.stash_all(path, branch_name, user, stash_modules)
|
23
23
|
|
24
24
|
# Switch to new feature
|
25
|
-
GitOperator.new.
|
25
|
+
GitOperator.new.checkout(path, branch_name)
|
26
26
|
GitOperator.new.pull(path)
|
27
27
|
|
28
28
|
# Apply home stash
|
@@ -32,7 +32,7 @@ module BigKeeper
|
|
32
32
|
BigkeeperParser.module_names, ModuleType::PATH)
|
33
33
|
|
34
34
|
modules.each do |module_name|
|
35
|
-
ModuleService.new.
|
35
|
+
ModuleService.new.switch_to(path, user, module_name, branch_name, type)
|
36
36
|
end
|
37
37
|
|
38
38
|
# pod install
|
@@ -13,15 +13,15 @@ require 'big_keeper/service/module_service'
|
|
13
13
|
|
14
14
|
|
15
15
|
module BigKeeper
|
16
|
-
def self.
|
16
|
+
def self.update(path, user, modules, type)
|
17
17
|
begin
|
18
18
|
# Parse Bigkeeper file
|
19
19
|
BigkeeperParser.parse("#{path}/Bigkeeper")
|
20
|
-
|
21
20
|
branch_name = GitOperator.new.current_branch(path)
|
22
|
-
Logger.error("Not a feature branch, exit.") unless branch_name.include? 'feature'
|
23
21
|
|
24
|
-
|
22
|
+
Logger.error("Not a #{GitflowType.name(type)} branch, exit.") unless branch_name.include? GitflowType.name(type)
|
23
|
+
|
24
|
+
full_name = branch_name.gsub(/#{GitflowType.name(type)}\//, '')
|
25
25
|
|
26
26
|
current_modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
|
27
27
|
BigkeeperParser.module_names, ModuleType::PATH)
|
@@ -41,15 +41,15 @@ module BigKeeper
|
|
41
41
|
del_modules = current_modules - modules
|
42
42
|
|
43
43
|
if add_modules.empty? and del_modules.empty?
|
44
|
-
Logger.
|
44
|
+
Logger.default("There is nothing changed with modules #{modules}.")
|
45
45
|
else
|
46
46
|
# Modify podfile as path and Start modules feature
|
47
47
|
add_modules.each do |module_name|
|
48
|
-
ModuleService.new.add(path, user, module_name,
|
48
|
+
ModuleService.new.add(path, user, module_name, full_name, type)
|
49
49
|
end
|
50
50
|
|
51
51
|
del_modules.each do |module_name|
|
52
|
-
ModuleService.new.del(path, user, module_name,
|
52
|
+
ModuleService.new.del(path, user, module_name, full_name, type)
|
53
53
|
end
|
54
54
|
|
55
55
|
# pod install
|
@@ -16,12 +16,12 @@ module BigKeeper
|
|
16
16
|
if GitOperator.new.has_branch(path, "release/#{version}")
|
17
17
|
if GitOperator.new.current_branch(path) == "release/#{version}"
|
18
18
|
GitOperator.new.commit(path, "release: V #{version}")
|
19
|
-
GitOperator.new.
|
19
|
+
GitOperator.new.push_to_remote(path, "release/#{version}")
|
20
20
|
GitflowOperator.new.finish_release(path, version)
|
21
21
|
if GitOperator.new.current_branch(path) == "master"
|
22
22
|
GitOperator.new.tag(path, version)
|
23
23
|
else
|
24
|
-
GitOperator.new.
|
24
|
+
GitOperator.new.checkout(path, "master")
|
25
25
|
GitOperator.new.tag(path, version)
|
26
26
|
end
|
27
27
|
else
|
@@ -43,10 +43,10 @@ module BigKeeper
|
|
43
43
|
# step 1 checkout release
|
44
44
|
if GitOperator.new.current_branch(project_path) != "release/#{version}"
|
45
45
|
if GitOperator.new.has_branch(project_path, "release/#{version}")
|
46
|
-
GitOperator.new.
|
46
|
+
GitOperator.new.checkout(project_path, "release/#{version}")
|
47
47
|
else
|
48
48
|
GitflowOperator.new.start(project_path, version, GitflowType::RELEASE)
|
49
|
-
GitOperator.new.
|
49
|
+
GitOperator.new.push_to_remote(project_path, "release/#{version}")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'big_keeper/util/podfile_operator'
|
3
|
+
require 'big_keeper/util/gitflow_operator'
|
4
|
+
require 'big_keeper/model/podfile_type'
|
5
|
+
require 'big_keeper/util/info_plist_operator'
|
6
|
+
require 'big_keeper/util/git_operator'
|
7
|
+
require 'big_keeper/util/logger'
|
8
|
+
|
9
|
+
module BigKeeper
|
10
|
+
def self.release_module_start(path, version, user, module_name)
|
11
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
12
|
+
|
13
|
+
Dir.chdir(path) do
|
14
|
+
git_info = GitInfo.new(BigkeeperParser::home_git, GitType::TAG, version)
|
15
|
+
module_path = self.get_module_path_default(path, user, module_name)
|
16
|
+
start_module_release(module_path, version, module_name, git_info, user)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.release_module_finish(path, version, user, module_name)
|
21
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
22
|
+
module_path = self.get_module_path_default(path, user, module_name)
|
23
|
+
|
24
|
+
Logger.error("current branch has changed") unless GitOperator.new.has_changes(module_path)
|
25
|
+
# check out master
|
26
|
+
if GitOperator.new.current_branch(module_path) != "master"
|
27
|
+
current_name = GitOperator.new.current_branch(module_path)
|
28
|
+
GitOperator.new.checkout(module_path, "master")
|
29
|
+
Logger.highlight("Push branch '#{current_name}' for '#{module_name}'...")
|
30
|
+
GitService.new.verify_push(module_path, "finish #{GitflowType.name(GitflowType::RELEASE)} #{current_name}", "master", "#{module_name}")
|
31
|
+
end
|
32
|
+
return
|
33
|
+
|
34
|
+
Dir.chdir(module_path) do
|
35
|
+
# rebase develop to master
|
36
|
+
Logger.highlight(%Q(Rebase develop to master))
|
37
|
+
|
38
|
+
#修改 podspec 文件
|
39
|
+
# TO DO: - advanced to use Regular Expression
|
40
|
+
PodfileOperator.new.podspec_change(%Q(#{module_path}/#{module_name}.podspec), version, module_name)
|
41
|
+
|
42
|
+
GitService.new.verify_rebase(module_path, 'develop', "#{module_name}")
|
43
|
+
GitOperator.new.verify_push(module_path, "finish rebase develop to master", "master", "#{module_name}")
|
44
|
+
GitOperator.new.tag(module_path, version)
|
45
|
+
|
46
|
+
Logger.highlight(%Q(Start Pod repo push #{module_name}))
|
47
|
+
IO.popen("pod repo push #{module_name} #{module_name}.podspec --allow-warnings --sources=#{BigkeeperParser::sourcemodule_path}") do |io|
|
48
|
+
io.each do |line|
|
49
|
+
has_error = true if line.include? "ERROR"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
if has_error
|
53
|
+
Logger.error("Pod repo push in '#{module_name}'")
|
54
|
+
return
|
55
|
+
end
|
56
|
+
|
57
|
+
Logger.highlight(%Q(Success release #{module_name} V#{version}))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
def self.start_module_release(module_path, version, module_name, source, user)
|
63
|
+
if GitOperator.new.has_changes(module_path)
|
64
|
+
StashService.new.stash_all(module_path, GitOperator.new.current_branch(module_path), user, module_name.split())
|
65
|
+
end
|
66
|
+
|
67
|
+
# step 1 checkout to develop branch
|
68
|
+
Logger.highlight(%Q(Start checkout #{module_name} to Branch develop))
|
69
|
+
if GitOperator.new.current_branch(module_path) != "develop"
|
70
|
+
if GitOperator.new.has_branch(module_path, "develop")
|
71
|
+
GitOperator.new.checkout(module_path, "develop")
|
72
|
+
else
|
73
|
+
Logger.error("Cann't find develop branch, please check.")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
Dir.chdir(module_path) do
|
78
|
+
# Pod lib lint
|
79
|
+
Logger.highlight(%Q(Start Pod lib lint #{module_name}))
|
80
|
+
has_error = false
|
81
|
+
IO.popen("pod lib lint --allow-warnings --verbose --use-libraries --sources=#{BigkeeperParser::sourcemodule_path}") do |io|
|
82
|
+
io.each do |line|
|
83
|
+
has_error = true if line.include? "ERROR"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
if has_error
|
87
|
+
Logger.error("Pod lib error in '#{module_name}'")
|
88
|
+
return
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
GitOperator.new.commit(module_path, "update podspec")
|
93
|
+
GitOperator.new.first_push(module_path, GitOperator.new.current_branch(module_path))
|
94
|
+
Logger.highlight(%Q(Pod lib lint success))
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.get_module_path_default(path, user, module_name)
|
98
|
+
module_path = BigkeeperParser::module_path(user, module_name)
|
99
|
+
if module_path == "../#{module_name}"
|
100
|
+
path_array = path.split('/')
|
101
|
+
path_array.pop()
|
102
|
+
module_path = path_array.join('/') + "/#{module_name}"
|
103
|
+
end
|
104
|
+
module_path
|
105
|
+
end
|
106
|
+
end
|
@@ -12,7 +12,19 @@ module BigKeeper
|
|
12
12
|
elsif RELEASE == type
|
13
13
|
"release"
|
14
14
|
else
|
15
|
-
|
15
|
+
"feature"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.base_branch(type)
|
20
|
+
if FEATURE == type
|
21
|
+
"develop"
|
22
|
+
elsif HOTFIX == type
|
23
|
+
"master"
|
24
|
+
elsif RELEASE == type
|
25
|
+
"develop"
|
26
|
+
else
|
27
|
+
"master"
|
16
28
|
end
|
17
29
|
end
|
18
30
|
end
|
@@ -7,70 +7,82 @@ module BigKeeper
|
|
7
7
|
# Operator for got
|
8
8
|
class GitService
|
9
9
|
def start(path, name, type)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
git = GitOperator.new
|
11
|
+
|
12
|
+
branch_name = "#{GitflowType.name(type)}/#{name}"
|
13
|
+
if !git.has_remote_branch(path, branch_name) && !git.has_local_branch(path, branch_name)
|
14
|
+
|
15
|
+
verify_special_branch(path, 'master')
|
16
|
+
verify_special_branch(path, 'develop')
|
17
|
+
|
18
|
+
GitflowOperator.new.start(path, name, type)
|
19
|
+
git.push_to_remote(path, branch_name)
|
20
|
+
else
|
21
|
+
verify_checkout(path, branch_name)
|
22
|
+
|
23
|
+
if !git.has_remote_branch(path, branch_name)
|
24
|
+
git.push_to_remote(path, branch_name)
|
20
25
|
end
|
21
26
|
end
|
27
|
+
end
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
def verify_checkout(path, branch_name)
|
30
|
+
Dir.chdir(path) do
|
31
|
+
cmd = "git checkout -b #{branch_name}"
|
32
|
+
if GitOperator.new.has_branch(path, branch_name)
|
33
|
+
cmd = "git checkout #{branch_name}"
|
34
|
+
end
|
35
|
+
IO.popen(cmd) do |io|
|
36
|
+
io.each do |line|
|
37
|
+
Logger.error("Checkout #{branch_name} failed.") if line.include? 'error'
|
30
38
|
end
|
31
|
-
else
|
32
|
-
GitOperator.new.git_checkout(path, 'develop')
|
33
39
|
end
|
34
40
|
end
|
41
|
+
end
|
35
42
|
|
36
|
-
|
37
|
-
|
38
|
-
GitOperator.new.first_push(path, 'master') if !GitOperator.new.has_remote_branch(path, 'master')
|
39
|
-
end
|
43
|
+
def verify_special_branch(path, name)
|
44
|
+
git = GitOperator.new
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
46
|
+
if git.has_remote_branch(path, name)
|
47
|
+
if git.has_local_branch(path, name)
|
48
|
+
if git.has_commits(path, name)
|
49
|
+
Logger.error(%Q('#{name}' has unpushed commits, you should fix it manually...))
|
50
|
+
end
|
51
|
+
pull(path, name)
|
52
|
+
else
|
53
|
+
git.checkout(path, name)
|
54
|
+
end
|
45
55
|
else
|
46
|
-
|
47
|
-
|
56
|
+
verify_checkout(path, name)
|
57
|
+
git.push_to_remote(path, name)
|
48
58
|
end
|
49
59
|
end
|
50
60
|
|
51
|
-
def
|
61
|
+
def verify_home_branch(path, branch_name, type)
|
52
62
|
Logger.highlight('Sync local branchs from remote, waiting...')
|
53
|
-
GitOperator.new
|
63
|
+
git = GitOperator.new
|
64
|
+
|
65
|
+
git.fetch(path)
|
54
66
|
|
55
67
|
if OperateType::START == type
|
56
|
-
if
|
68
|
+
if git.current_branch(path) == branch_name
|
57
69
|
Logger.error(%(Current branch is '#{branch_name}' already. Use 'update' please))
|
58
70
|
end
|
59
|
-
if
|
71
|
+
if git.has_branch(path, branch_name)
|
60
72
|
Logger.error(%(Branch '#{branch_name}' already exists. Use 'switch' please))
|
61
73
|
end
|
62
74
|
elsif OperateType::SWITCH == type
|
63
|
-
if !
|
75
|
+
if !git.has_branch(path, branch_name)
|
64
76
|
Logger.error(%(Can't find a branch named '#{branch_name}'. Use 'start' please))
|
65
77
|
end
|
66
|
-
if
|
78
|
+
if git.current_branch(path) == branch_name
|
67
79
|
Logger.error(%(Current branch is '#{branch_name}' already. Use 'update' please))
|
68
80
|
end
|
69
81
|
elsif OperateType::UPDATE == type
|
70
|
-
if !
|
82
|
+
if !git.has_branch(path, branch_name)
|
71
83
|
Logger.error(%(Can't find a branch named '#{branch_name}'. Use 'start' please))
|
72
84
|
end
|
73
|
-
if
|
85
|
+
if git.current_branch(path) != branch_name
|
74
86
|
Logger.error(%(Current branch is not '#{branch_name}'. Use 'switch' please))
|
75
87
|
end
|
76
88
|
else
|
@@ -90,14 +102,46 @@ module BigKeeper
|
|
90
102
|
branchs
|
91
103
|
end
|
92
104
|
|
105
|
+
def pull(path, branch_name)
|
106
|
+
git = GitOperator.new
|
107
|
+
if git.current_branch(path) == branch_name
|
108
|
+
git.pull(path)
|
109
|
+
else
|
110
|
+
Dir.chdir(path) do
|
111
|
+
`git pull origin #{branch_name}:#{branch_name}`
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def verify_del(path, branch_name, name, type)
|
117
|
+
git = GitOperator.new
|
118
|
+
|
119
|
+
if git.has_local_branch(path, branch_name)
|
120
|
+
Logger.highlight("Delete local branch '#{branch_name}' for '#{name}'...")
|
121
|
+
|
122
|
+
if git.current_branch(path) == branch_name
|
123
|
+
git.dicard(path)
|
124
|
+
git.checkout(path, GitflowType.base_branch(type))
|
125
|
+
end
|
126
|
+
git.del_local(path, branch_name)
|
127
|
+
end
|
128
|
+
|
129
|
+
if git.has_remote_branch(path, branch_name)
|
130
|
+
Logger.highlight("Delete remote branch '#{branch_name}' for '#{name}'...")
|
131
|
+
git.del_remote(path, branch_name)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
93
135
|
def verify_push(path, comment, branch_name, name)
|
94
136
|
git = GitOperator.new
|
95
137
|
if git.has_changes(path)
|
96
138
|
git.commit(path, comment)
|
97
139
|
if git.has_remote_branch(path, branch_name)
|
98
|
-
|
140
|
+
Dir.chdir(path) do
|
141
|
+
`git push`
|
142
|
+
end
|
99
143
|
else
|
100
|
-
git.
|
144
|
+
git.push_to_remote(path, branch_name)
|
101
145
|
end
|
102
146
|
else
|
103
147
|
Logger.default("Nothing to push for '#{name}'.")
|
@@ -126,7 +170,7 @@ module BigKeeper
|
|
126
170
|
end
|
127
171
|
end
|
128
172
|
`git push -f origin #{branch_name}`
|
129
|
-
GitOperator.new.
|
173
|
+
GitOperator.new.checkout(path, 'develop')
|
130
174
|
end
|
131
175
|
end
|
132
176
|
end
|
@@ -4,91 +4,81 @@ require 'big_keeper/util/logger'
|
|
4
4
|
module BigKeeper
|
5
5
|
# Operator for got
|
6
6
|
class ModuleService
|
7
|
-
def pull(path, user, module_name, branch_name)
|
8
|
-
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
9
7
|
|
10
|
-
|
8
|
+
def verify_module(path, user, module_name, home_branch_name, type)
|
9
|
+
name = home_branch_name.gsub(/#{GitflowType.name(type)}\//, '')
|
10
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
11
11
|
|
12
|
+
git = GitOperator.new
|
12
13
|
if !File.exist? module_full_path
|
13
14
|
Logger.default("No local repository for module '#{module_name}', clone it...")
|
14
15
|
module_git = BigkeeperParser.module_git(module_name)
|
15
|
-
|
16
|
-
GitOperator.new.git_checkout(module_full_path, branch_name)
|
17
|
-
else
|
18
|
-
current_branch_name = GitOperator.new.current_branch(module_full_path)
|
19
|
-
if current_branch_name != branch_name
|
20
|
-
Logger.default("Current branch of '#{module_name}' is '#{current_branch_name}',\
|
21
|
-
stash it and checkout '#{branch_name}'...")
|
22
|
-
|
23
|
-
StashService.new.stash(module_full_path, current_branch_name, module_name)
|
24
|
-
|
25
|
-
GitOperator.new.git_checkout(module_full_path, branch_name)
|
26
|
-
end
|
27
|
-
GitOperator.new.pull(module_full_path)
|
16
|
+
git.new.clone(File.expand_path("#{module_full_path}/../"), module_git)
|
28
17
|
end
|
29
|
-
end
|
30
18
|
|
31
|
-
|
32
|
-
|
19
|
+
current_branch_name = git.current_branch(module_full_path)
|
20
|
+
if current_branch_name != home_branch_name
|
21
|
+
# stash current branch
|
22
|
+
StashService.new.stash(module_full_path, current_branch_name, module_name)
|
33
23
|
|
34
|
-
|
24
|
+
GitService.new.start(module_full_path, name, type)
|
35
25
|
|
36
|
-
|
37
|
-
Logger.default("No local repository for module '#{module_name}', clone it...")
|
38
|
-
module_git = BigkeeperParser.module_git(module_name)
|
39
|
-
GitOperator.new.clone(File.expand_path("#{module_full_path}/../"), module_git)
|
40
|
-
GitOperator.new.git_checkout(module_full_path, branch_name)
|
41
|
-
else
|
42
|
-
GitOperator.new.git_checkout(module_full_path, branch_name)
|
43
|
-
GitOperator.new.pull(module_full_path)
|
26
|
+
StashService.new.pop_stash(module_full_path, home_branch_name, module_name)
|
44
27
|
end
|
45
|
-
|
46
|
-
StashService.new.pop_stash(module_full_path, branch_name, module_name)
|
47
28
|
end
|
48
29
|
|
49
|
-
def
|
50
|
-
|
30
|
+
def push(path, user, module_name, home_branch_name, type, comment)
|
31
|
+
Logger.highlight("Push branch '#{home_branch_name}' for module '#{module_name}'...")
|
32
|
+
|
33
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
34
|
+
|
51
35
|
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
52
|
-
|
36
|
+
GitService.new.verify_push(module_full_path, comment, home_branch_name, module_name)
|
37
|
+
end
|
53
38
|
|
54
|
-
|
39
|
+
def pull(path, user, module_name, home_branch_name, type)
|
40
|
+
Logger.highlight("Pull branch '#{home_branch_name}' for module '#{module_name}'...")
|
55
41
|
|
56
|
-
|
57
|
-
module_name,
|
58
|
-
ModuleType::GIT,
|
59
|
-
GitInfo.new(module_git, GitType::BRANCH, branch_name))
|
42
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
60
43
|
|
61
|
-
|
44
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
45
|
+
GitOperator.new.pull(module_full_path)
|
46
|
+
end
|
62
47
|
|
63
|
-
|
48
|
+
def switch_to(path, user, module_name, home_branch_name, type)
|
49
|
+
Logger.highlight("Switch to branch '#{home_branch_name}' for module '#{module_name}'...")
|
50
|
+
|
51
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
64
52
|
end
|
65
53
|
|
66
|
-
def
|
67
|
-
|
54
|
+
def finish(path, user, module_name, home_branch_name, type)
|
55
|
+
Logger.highlight("Finish branch '#{home_branch_name}' for module '#{module_name}'...")
|
56
|
+
|
57
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
68
58
|
|
69
|
-
|
59
|
+
module_git = BigkeeperParser.module_git(module_name)
|
60
|
+
PodfileOperator.new.find_and_replace("#{path}/Podfile",
|
61
|
+
module_name,
|
62
|
+
ModuleType::GIT,
|
63
|
+
GitInfo.new(module_git, GitType::BRANCH, home_branch_name))
|
70
64
|
|
71
65
|
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
72
66
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
module_git = BigkeeperParser.module_git(module_name)
|
77
|
-
GitOperator.new.clone(File.expand_path("#{module_full_path}/../"), module_git)
|
78
|
-
end
|
67
|
+
GitService.new.verify_push(module_full_path, "finish branch #{home_branch_name}", home_branch_name, module_name)
|
68
|
+
|
69
|
+
GitService.new.verify_rebase(module_full_path, GitflowType.base_branch(type), module_name)
|
79
70
|
|
80
|
-
#
|
81
|
-
|
71
|
+
`open #{BigkeeperParser.module_pulls(module_name)}`
|
72
|
+
end
|
82
73
|
|
83
|
-
|
74
|
+
def add(path, user, module_name, name, type)
|
75
|
+
home_branch_name = "#{GitflowType.name(type)}/#{name}"
|
76
|
+
Logger.highlight("Add branch '#{home_branch_name}' for module '#{module_name}'...")
|
84
77
|
|
85
|
-
# start new feature/hotfix
|
86
|
-
GitService.new.start(module_full_path, name, type)
|
87
78
|
|
88
|
-
|
79
|
+
verify_module(path, user, module_name, home_branch_name, type)
|
89
80
|
|
90
81
|
module_path = BigkeeperParser.module_path(user, module_name)
|
91
|
-
|
92
82
|
PodfileOperator.new.find_and_replace("#{path}/Podfile",
|
93
83
|
module_name,
|
94
84
|
ModuleType::PATH,
|
@@ -96,23 +86,23 @@ module BigKeeper
|
|
96
86
|
end
|
97
87
|
|
98
88
|
def del(path, user, module_name, name, type)
|
99
|
-
|
89
|
+
home_branch_name = "#{GitflowType.name(type)}/#{name}"
|
100
90
|
|
101
|
-
Logger.highlight("Delete branch '#{
|
91
|
+
Logger.highlight("Delete branch '#{home_branch_name}' for module '#{module_name}'...")
|
102
92
|
|
103
93
|
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
104
94
|
|
105
|
-
StashService.new.stash(module_full_path,
|
95
|
+
StashService.new.stash(module_full_path, home_branch_name, module_name)
|
106
96
|
|
107
|
-
GitOperator.new.
|
108
|
-
GitOperator.new.del(module_full_path,
|
97
|
+
GitOperator.new.checkout(module_full_path, GitflowType.base_branch(type))
|
98
|
+
# GitOperator.new.del(module_full_path, home_branch_name)
|
109
99
|
|
110
100
|
module_git = BigkeeperParser.module_git(module_name)
|
111
101
|
|
112
102
|
PodfileOperator.new.find_and_replace("#{path}/Podfile",
|
113
103
|
module_name,
|
114
104
|
ModuleType::GIT,
|
115
|
-
GitInfo.new(module_git, GitType::BRANCH,
|
105
|
+
GitInfo.new(module_git, GitType::BRANCH, GitflowType.base_branch(type)))
|
116
106
|
end
|
117
107
|
end
|
118
108
|
end
|