bigkeeper 0.7.8 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/Gemfile.lock +2 -2
- data/lib/big_keeper/command/feature&hotfix.rb +4 -5
- data/lib/big_keeper/command/feature&hotfix/delete.rb +6 -1
- data/lib/big_keeper/command/feature&hotfix/finish.rb +11 -5
- data/lib/big_keeper/command/feature&hotfix/list.rb +42 -0
- data/lib/big_keeper/command/feature&hotfix/publish.rb +9 -8
- data/lib/big_keeper/command/feature&hotfix/start.rb +11 -26
- data/lib/big_keeper/command/feature&hotfix/switch.rb +3 -3
- data/lib/big_keeper/command/feature&hotfix/update.rb +9 -18
- data/lib/big_keeper/dependency/dep_gradle_operator.rb +28 -28
- data/lib/big_keeper/dependency/dep_operator.rb +1 -1
- data/lib/big_keeper/dependency/dep_pod_operator.rb +36 -18
- data/lib/big_keeper/dependency/dep_type.rb +0 -31
- data/lib/big_keeper/model/operate_type.rb +8 -0
- data/lib/big_keeper/service/git_service.rb +17 -0
- data/lib/big_keeper/service/module_service.rb +38 -27
- data/lib/big_keeper/util/bigkeeper_parser.rb +3 -0
- data/lib/big_keeper/util/cache_operator.rb +29 -12
- data/lib/big_keeper/util/git_operator.rb +4 -4
- data/lib/big_keeper/util/gradle_operator.rb +136 -78
- data/lib/big_keeper/util/list_generator.rb +29 -0
- data/lib/big_keeper/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 028f56615f3e793abad38eed28a1f898564632a3
|
4
|
+
data.tar.gz: 2143d81a7144a0611bd4bb5ec5ba3fe8d34a032d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 767a5d482e00d1eefb7a95863d8c1990405656187ee168edb9726ab78e5f8d07398349fac58a52404c3edb9dc6f1296fbd6bbaac22a7da174ae12ae5a90e819e
|
7
|
+
data.tar.gz: 2dcd82312c0cb2dc2c387cff5ac9e588f216c70e4ea8311d1b1626c6fb67c84c0fe3f231f4ce4aad260ba29c011a9f71a9e017a4c7e07e5cf0d0ee2757895fd2
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bigkeeper (0.7.
|
4
|
+
bigkeeper (0.7.8)
|
5
5
|
big_stash (~> 0.1)
|
6
6
|
cocoapods
|
7
7
|
colorize
|
@@ -63,7 +63,7 @@ GEM
|
|
63
63
|
gh_inspector (1.0.2)
|
64
64
|
gli (2.17.1)
|
65
65
|
i18n (0.7.0)
|
66
|
-
json (1.8.
|
66
|
+
json (1.8.6)
|
67
67
|
minitest (5.8.3)
|
68
68
|
molinillo (0.5.7)
|
69
69
|
nanaimo (0.2.3)
|
@@ -7,6 +7,7 @@ require 'big_keeper/command/feature&hotfix/push'
|
|
7
7
|
require 'big_keeper/command/feature&hotfix/rebase'
|
8
8
|
require 'big_keeper/command/feature&hotfix/publish'
|
9
9
|
require 'big_keeper/command/feature&hotfix/delete'
|
10
|
+
require 'big_keeper/command/feature&hotfix/list'
|
10
11
|
|
11
12
|
module BigKeeper
|
12
13
|
def self.feature_and_hotfix_command(type)
|
@@ -127,12 +128,10 @@ module BigKeeper
|
|
127
128
|
c.desc "List all the #{GitflowType.name(type)}s"
|
128
129
|
c.command :list do |list|
|
129
130
|
list.action do |global_options, options, args|
|
131
|
+
Logger.highlight("Generating feature tree of all version...") if args.length < 1
|
130
132
|
path = File.expand_path(global_options[:path])
|
131
|
-
|
132
|
-
|
133
|
-
branchs.each do |branch|
|
134
|
-
p branch
|
135
|
-
end
|
133
|
+
user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
|
134
|
+
list(path,user,type)
|
136
135
|
end
|
137
136
|
end
|
138
137
|
end
|
@@ -25,9 +25,14 @@ module BigKeeper
|
|
25
25
|
|
26
26
|
modules.each do |module_name|
|
27
27
|
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
28
|
-
|
28
|
+
|
29
|
+
if FileOperator.definitely_exists?(module_full_path)
|
30
|
+
StashService.new.pop_stash(module_full_path, branch_name, module_name)
|
31
|
+
GitService.new.verify_del(module_full_path, branch_name, module_name, type)
|
32
|
+
end
|
29
33
|
end
|
30
34
|
|
35
|
+
StashService.new.pop_stash(path, branch_name, 'Home')
|
31
36
|
GitService.new.verify_del(path, branch_name, 'Home', type)
|
32
37
|
ensure
|
33
38
|
end
|
@@ -22,24 +22,30 @@ module BigKeeper
|
|
22
22
|
branch_name = GitOperator.new.current_branch(path)
|
23
23
|
Logger.error("Not a #{GitflowType.name(type)} branch, exit.") unless branch_name.include? GitflowType.name(type)
|
24
24
|
|
25
|
-
|
26
|
-
ModuleCacheOperator.new(path).
|
25
|
+
# Cache git modules
|
26
|
+
if ModuleCacheOperator.new(path).all_path_modules.empty?
|
27
|
+
Logger.error("Branch '#{branch_name}' is already finished, exit.")
|
28
|
+
end
|
27
29
|
|
28
|
-
|
30
|
+
ModuleCacheOperator.new(path).cache_git_modules(ModuleCacheOperator.new(path).all_path_modules)
|
29
31
|
|
30
|
-
|
32
|
+
modules = ModuleCacheOperator.new(path).remain_git_modules
|
33
|
+
# Rebase modules and modify module as git
|
31
34
|
modules.each do |module_name|
|
32
35
|
ModuleService.new.finish(path, user, module_name, branch_name, type)
|
33
36
|
end
|
34
37
|
|
35
38
|
Logger.highlight("Finish branch '#{branch_name}' for 'Home'")
|
36
39
|
|
37
|
-
#
|
40
|
+
# Install
|
38
41
|
DepService.dep_operator(path, user).install(false)
|
39
42
|
|
40
43
|
# Open home workspace
|
41
44
|
DepService.dep_operator(path, user).open
|
42
45
|
|
46
|
+
# Delete all path modules
|
47
|
+
ModuleCacheOperator.new(path).cache_path_modules([], [], [])
|
48
|
+
|
43
49
|
# Push home changes to remote
|
44
50
|
GitService.new.verify_push(path, "finish branch #{branch_name}", branch_name, 'Home')
|
45
51
|
ensure
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'big_keeper/util/bigkeeper_parser'
|
3
|
+
require 'big_keeper/util/list_generator'
|
4
|
+
require 'big_keeper/service/module_service'
|
5
|
+
|
6
|
+
|
7
|
+
module BigKeeper
|
8
|
+
def self.list(path,user,type)
|
9
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
10
|
+
#get home project branches
|
11
|
+
branches = GitService.new.branchs_with_type(File.expand_path(path), type)
|
12
|
+
#get modules list
|
13
|
+
begin
|
14
|
+
modules = BigkeeperParser.module_names
|
15
|
+
file = File.new("#{path}/.bigkeeper/feature_list", 'w')
|
16
|
+
begin
|
17
|
+
#read git info
|
18
|
+
git_operator = GitOperator.new
|
19
|
+
modules.each do |module_name|
|
20
|
+
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
21
|
+
#local project verify
|
22
|
+
if !File.exist? module_full_path
|
23
|
+
Logger.default("No local repository for module '#{module_name}', clone it...")
|
24
|
+
module_git = BigkeeperParser.module_git(module_name)
|
25
|
+
git_operator.clone(File.expand_path("#{module_full_path}/../"), module_git)
|
26
|
+
end
|
27
|
+
feature_modules_list = ModuleService.new.list(module_full_path, user, module_name)
|
28
|
+
dic = {}
|
29
|
+
dic[module_name] = feature_modules_list
|
30
|
+
file << dic
|
31
|
+
file << "\n\n"
|
32
|
+
end
|
33
|
+
file.close
|
34
|
+
end
|
35
|
+
|
36
|
+
#print list
|
37
|
+
ListGenerator.generate(file,branches)
|
38
|
+
ensure
|
39
|
+
file.close
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -25,26 +25,27 @@ module BigKeeper
|
|
25
25
|
path_modules = ModuleCacheOperator.new(path).current_path_modules
|
26
26
|
Logger.error("You have unfinished modules #{path_modules}, Use 'finish' first please.") unless path_modules.empty?
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
# Push modules changes to remote then rebase
|
30
29
|
modules = ModuleCacheOperator.new(path).current_git_modules
|
30
|
+
modules.each do |module_name|
|
31
|
+
ModuleService.new.pre_publish(path, user, module_name, branch_name, type)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Install
|
35
|
+
DepService.dep_operator(path, user).install(false)
|
31
36
|
|
32
|
-
#
|
37
|
+
# Modify module as git
|
33
38
|
modules.each do |module_name|
|
34
39
|
ModuleService.new.publish(path, user, module_name, branch_name, type)
|
35
40
|
end
|
36
41
|
|
37
42
|
Logger.highlight("Publish branch '#{branch_name}' for 'Home'")
|
38
43
|
|
39
|
-
#
|
40
|
-
DepService.dep_operator(path, user).install(false)
|
41
|
-
|
42
|
-
# Recover podfile
|
44
|
+
# Recover home
|
43
45
|
DepService.dep_operator(path, user).recover
|
44
46
|
|
45
47
|
# Push home changes to remote
|
46
48
|
GitService.new.verify_push(path, "publish branch #{branch_name}", branch_name, 'Home')
|
47
|
-
|
48
49
|
# Rebase Home
|
49
50
|
GitService.new.verify_rebase(path, GitflowType.base_branch(type), 'Home')
|
50
51
|
|
@@ -28,58 +28,43 @@ module BigKeeper
|
|
28
28
|
|
29
29
|
GitService.new.verify_home_branch(path, branch_name, OperateType::START)
|
30
30
|
|
31
|
-
stash_modules = ModuleCacheOperator.new(path).
|
31
|
+
stash_modules = ModuleCacheOperator.new(path).all_path_modules
|
32
32
|
|
33
33
|
# Stash current branch
|
34
34
|
StashService.new.stash_all(path, branch_name, user, stash_modules)
|
35
35
|
|
36
36
|
# Verify input modules
|
37
|
-
modules =
|
38
|
-
BigkeeperParser.verify_modules(modules)
|
39
|
-
|
40
|
-
# # Handle modules
|
41
|
-
# if modules
|
42
|
-
# # Verify input modules
|
43
|
-
# BigkeeperParser.verify_modules(modules)
|
44
|
-
# else
|
45
|
-
# # Get all modules if not specified
|
46
|
-
# modules = BigkeeperParser.module_names
|
47
|
-
# end
|
37
|
+
modules = BigkeeperParser.verify_modules(modules)
|
48
38
|
|
49
39
|
Logger.highlight("Add branch '#{branch_name}' for 'Home'...")
|
50
40
|
# Start home feature
|
51
41
|
GitService.new.start(path, full_name, type)
|
52
42
|
|
53
|
-
|
43
|
+
# Cache all path modules
|
44
|
+
ModuleCacheOperator.new(path).cache_path_modules(modules, modules, [])
|
45
|
+
modules = ModuleCacheOperator.new(path).remain_path_modules
|
54
46
|
|
55
|
-
# Backup
|
47
|
+
# Backup home
|
56
48
|
DepService.dep_operator(path, user).backup
|
57
49
|
|
58
|
-
#
|
50
|
+
# Start modules feature and modify module as path
|
59
51
|
modules.each do |module_name|
|
60
52
|
ModuleService.new.add(path, user, module_name, full_name, type)
|
61
53
|
end
|
62
54
|
|
63
|
-
#
|
55
|
+
# install
|
64
56
|
DepService.dep_operator(path, user).install(true)
|
65
57
|
|
66
58
|
# Open home workspace
|
67
59
|
DepService.dep_operator(path, user).open
|
68
60
|
|
69
61
|
# Push home changes to remote
|
70
|
-
|
62
|
+
Logger.highlight("Push branch '#{branch_name}' for 'Home'...")
|
63
|
+
GitService.new.verify_push(
|
64
|
+
path,
|
71
65
|
"init #{GitflowType.name(type)} #{full_name}",
|
72
66
|
branch_name,
|
73
67
|
'Home')
|
74
|
-
|
75
|
-
modules.each do |module_name|
|
76
|
-
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
77
|
-
# Push home changes to remote
|
78
|
-
GitService.new.verify_push(module_full_path,
|
79
|
-
"init #{GitflowType.name(type)} #{full_name}",
|
80
|
-
branch_name,
|
81
|
-
module_name)
|
82
|
-
end
|
83
68
|
ensure
|
84
69
|
end
|
85
70
|
end
|
@@ -18,7 +18,7 @@ module BigKeeper
|
|
18
18
|
|
19
19
|
GitService.new.verify_home_branch(path, branch_name, OperateType::SWITCH)
|
20
20
|
|
21
|
-
stash_modules = ModuleCacheOperator.new(path).
|
21
|
+
stash_modules = ModuleCacheOperator.new(path).all_path_modules
|
22
22
|
|
23
23
|
# Stash current branch
|
24
24
|
StashService.new.stash_all(path, branch_name, user, stash_modules)
|
@@ -30,13 +30,13 @@ module BigKeeper
|
|
30
30
|
# Apply home stash
|
31
31
|
StashService.new.pop_stash(path, branch_name, 'Home')
|
32
32
|
|
33
|
-
modules = ModuleCacheOperator.new(path).
|
33
|
+
modules = ModuleCacheOperator.new(path).all_path_modules
|
34
34
|
|
35
35
|
modules.each do |module_name|
|
36
36
|
ModuleService.new.switch_to(path, user, module_name, branch_name, type)
|
37
37
|
end
|
38
38
|
|
39
|
-
#
|
39
|
+
# Install
|
40
40
|
DepService.dep_operator(path, user).install(false)
|
41
41
|
|
42
42
|
# Open home workspace
|
@@ -30,43 +30,34 @@ module BigKeeper
|
|
30
30
|
current_modules = ModuleCacheOperator.new(path).current_path_modules
|
31
31
|
|
32
32
|
# Verify input modules
|
33
|
-
modules =
|
34
|
-
BigkeeperParser.verify_modules(modules)
|
35
|
-
|
36
|
-
# # Handle modules
|
37
|
-
# if modules
|
38
|
-
# # Verify input modules
|
39
|
-
# BigkeeperParser.verify_modules(modules)
|
40
|
-
# else
|
41
|
-
# # Get all modules if not specified
|
42
|
-
# modules = BigkeeperParser.module_names
|
43
|
-
# end
|
33
|
+
modules = BigkeeperParser.verify_modules(modules)
|
44
34
|
|
45
35
|
Logger.highlight("Start to update modules for branch '#{branch_name}'...")
|
46
36
|
|
47
37
|
add_modules = modules - current_modules
|
48
38
|
del_modules = current_modules - modules
|
49
39
|
|
50
|
-
ModuleCacheOperator.new(path).cache_path_modules(modules)
|
40
|
+
ModuleCacheOperator.new(path).cache_path_modules(modules, add_modules, del_modules)
|
41
|
+
remain_path_modules = ModuleCacheOperator.new(path).remain_path_modules
|
51
42
|
|
52
43
|
if add_modules.empty? and del_modules.empty?
|
53
44
|
Logger.default("There is nothing changed with modules #{modules}.")
|
54
45
|
else
|
55
46
|
# Modify podfile as path and Start modules feature
|
56
|
-
|
47
|
+
remain_path_modules.each do |module_name|
|
57
48
|
ModuleService.new.add(path, user, module_name, full_name, type)
|
58
49
|
end
|
59
50
|
|
60
51
|
del_modules.each do |module_name|
|
61
52
|
ModuleService.new.del(path, user, module_name, full_name, type)
|
62
53
|
end
|
54
|
+
end
|
63
55
|
|
64
|
-
|
65
|
-
|
56
|
+
# Install
|
57
|
+
DepService.dep_operator(path, user).install(false)
|
66
58
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
59
|
+
# Open home workspace
|
60
|
+
DepService.dep_operator(path, user).open
|
70
61
|
ensure
|
71
62
|
end
|
72
63
|
end
|
@@ -7,47 +7,47 @@ module BigKeeper
|
|
7
7
|
|
8
8
|
def backup
|
9
9
|
GradleOperator.new(@path).backup
|
10
|
+
modules = ModuleCacheOperator.new(@path).all_path_modules
|
11
|
+
modules.each do |module_name|
|
12
|
+
module_full_path = BigkeeperParser.module_full_path(@path, @user, module_name)
|
13
|
+
GradleOperator.new(module_full_path).backup
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
def recover
|
13
|
-
GradleOperator.new(@path).recover
|
18
|
+
GradleOperator.new(@path).recover(true, false)
|
14
19
|
end
|
15
20
|
|
16
|
-
def update_module_config(module_name,
|
17
|
-
GradleOperator.new(@path).update_module_config(module_name, module_type, source)
|
18
|
-
|
21
|
+
def update_module_config(module_name, module_operate_type)
|
19
22
|
module_full_path = BigkeeperParser.module_full_path(@path, @user, module_name)
|
20
23
|
|
21
|
-
|
24
|
+
# get modules
|
25
|
+
if ModuleOperateType::ADD == module_operate_type
|
22
26
|
GradleOperator.new(module_full_path).backup
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
28
|
+
add_modules = ModuleCacheOperator.new(@path).add_path_modules
|
29
|
+
GradleOperator.new(module_full_path).update_build_config(module_name, add_modules, ModuleOperateType::ADD)
|
30
|
+
GradleOperator.new(module_full_path).update_settings_config(module_name, add_modules, ModuleOperateType::ADD, @user)
|
31
|
+
|
32
|
+
del_modules = ModuleCacheOperator.new(@path).del_path_modules
|
33
|
+
GradleOperator.new(module_full_path).update_build_config(module_name, del_modules, ModuleOperateType::DELETE)
|
34
|
+
GradleOperator.new(module_full_path).update_settings_config(module_name, del_modules, ModuleOperateType::DELETE, @user)
|
35
|
+
elsif ModuleOperateType::DELETE == module_operate_type
|
36
|
+
GradleOperator.new(module_full_path).recover(true, true)
|
37
|
+
elsif ModuleOperateType::FINISH == module_operate_type
|
38
|
+
modules = ModuleCacheOperator.new(@path).all_path_modules
|
39
|
+
GradleOperator.new(module_full_path).update_build_config(module_name, modules, ModuleOperateType::FINISH)
|
40
|
+
elsif ModuleOperateType::PUBLISH == module_operate_type
|
41
|
+
modules = ModuleCacheOperator.new(@path).all_git_modules
|
42
|
+
GradleOperator.new(module_full_path).update_build_config(module_name, modules, ModuleOperateType::PUBLISH)
|
43
|
+
GradleOperator.new(module_full_path).recover(true, false)
|
40
44
|
end
|
45
|
+
|
46
|
+
GradleOperator.new(@path).update_build_config('', [module_name], module_operate_type)
|
47
|
+
GradleOperator.new(@path).update_settings_config('', [module_name], module_operate_type, @user)
|
41
48
|
end
|
42
49
|
|
43
50
|
def install(should_update)
|
44
|
-
modules = ModuleCacheOperator.new(@path).all_path_modules
|
45
|
-
GradleOperator.new(@path).update_setting_config('', @user, modules)
|
46
|
-
|
47
|
-
modules.each do |module_name|
|
48
|
-
module_full_path = BigkeeperParser.module_full_path(@path, @user, module_name)
|
49
|
-
GradleOperator.new(module_full_path).update_setting_config(module_name, @user, modules)
|
50
|
-
end
|
51
51
|
end
|
52
52
|
|
53
53
|
def open
|
@@ -17,7 +17,7 @@ module BigKeeper
|
|
17
17
|
raise "You should override this method in subclass."
|
18
18
|
end
|
19
19
|
|
20
|
-
def update_module_config(module_name,
|
20
|
+
def update_module_config(module_name, module_operate_type)
|
21
21
|
raise "You should override this method in subclass."
|
22
22
|
end
|
23
23
|
|
@@ -17,14 +17,14 @@ module BigKeeper
|
|
17
17
|
cache_operator.clean
|
18
18
|
end
|
19
19
|
|
20
|
-
def update_module_config(module_name,
|
20
|
+
def update_module_config(module_name, module_operate_type)
|
21
21
|
file = "#{@path}/Podfile"
|
22
22
|
temp_file = Tempfile.new('.Podfile.tmp')
|
23
23
|
|
24
24
|
begin
|
25
25
|
File.open(file, 'r') do |file|
|
26
26
|
file.each_line do |line|
|
27
|
-
temp_file.puts generate_module_config(line, module_name,
|
27
|
+
temp_file.puts generate_module_config(line, module_name, module_operate_type)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
temp_file.close
|
@@ -43,30 +43,48 @@ module BigKeeper
|
|
43
43
|
XcodeOperator.open_workspace(@path)
|
44
44
|
end
|
45
45
|
|
46
|
-
def generate_module_config(line, module_name,
|
46
|
+
def generate_module_config(line, module_name, module_operate_type)
|
47
47
|
line.sub(/(\s*)pod(\s*)('|")#{module_name}('|")([\s\S]*)/){
|
48
|
-
if
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
if
|
54
|
-
|
55
|
-
elsif GitType::TAG == source.type
|
56
|
-
"#{$1}pod '#{module_name}', :git => '#{source.base}', :tag => '#{source.addition}'"
|
57
|
-
elsif GitType::COMMIT == source.type
|
58
|
-
"#{$1}pod '#{module_name}', :git => '#{source.base}', :commit => '#{source.addition}'"
|
48
|
+
if ModuleOperateType::ADD == module_operate_type
|
49
|
+
module_path = BigkeeperParser.module_path(@user, module_name)
|
50
|
+
"#{$1}pod '#{module_name}', :path => '#{module_path}'"
|
51
|
+
elsif ModuleOperateType::DELETE == module_operate_type
|
52
|
+
origin_config_of_module = origin_config_of_module(module_name)
|
53
|
+
if origin_config_of_module.empty?
|
54
|
+
line
|
59
55
|
else
|
60
|
-
|
56
|
+
origin_config_of_module
|
61
57
|
end
|
62
|
-
elsif
|
63
|
-
|
58
|
+
elsif ModuleOperateType::FINISH == module_operate_type
|
59
|
+
module_git = BigkeeperParser.module_git(module_name)
|
60
|
+
branch_name = GitOperator.new.current_branch(@path)
|
61
|
+
"#{$1}pod '#{module_name}', :git => '#{module_git}', :branch => '#{branch_name}'"
|
62
|
+
elsif ModuleOperateType::PUBLISH == module_operate_type
|
63
|
+
module_git = BigkeeperParser.module_git(module_name)
|
64
|
+
branch_name = GitOperator.new.current_branch(@path)
|
65
|
+
base_branch_name = GitflowType.base_branch(GitService.new.current_branch_type(@path))
|
66
|
+
"#{$1}pod '#{module_name}', :git => '#{module_git}', :branch => '#{base_branch_name}'"
|
64
67
|
else
|
65
68
|
line
|
66
69
|
end
|
67
70
|
}
|
68
71
|
end
|
69
72
|
|
70
|
-
|
73
|
+
def origin_config_of_module(module_name)
|
74
|
+
origin_config = ''
|
75
|
+
|
76
|
+
File.open("#{@path}/.bigkeeper/Podfile", 'r') do |file|
|
77
|
+
file.each_line do |line|
|
78
|
+
if line =~ /(\s*)pod(\s*)('|")#{module_name}('|")([\s\S]*)/
|
79
|
+
origin_config = line
|
80
|
+
break
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
origin_config.chop
|
86
|
+
end
|
87
|
+
|
88
|
+
private :generate_module_config, :origin_config_of_module
|
71
89
|
end
|
72
90
|
end
|
@@ -30,35 +30,4 @@ module BigKeeper
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
module ModuleType
|
35
|
-
PATH = 1
|
36
|
-
GIT = 2
|
37
|
-
SPEC = 3
|
38
|
-
end
|
39
|
-
|
40
|
-
module GitType
|
41
|
-
MASTER = 1
|
42
|
-
BRANCH = 2
|
43
|
-
TAG = 3
|
44
|
-
COMMIT = 4
|
45
|
-
end
|
46
|
-
|
47
|
-
class GitInfo
|
48
|
-
def initialize(base, type, addition)
|
49
|
-
@base, @type, @addition = base, type, addition
|
50
|
-
end
|
51
|
-
|
52
|
-
def type
|
53
|
-
@type
|
54
|
-
end
|
55
|
-
|
56
|
-
def base
|
57
|
-
@base
|
58
|
-
end
|
59
|
-
|
60
|
-
def addition
|
61
|
-
@addition
|
62
|
-
end
|
63
|
-
end
|
64
33
|
end
|
@@ -59,6 +59,10 @@ module BigKeeper
|
|
59
59
|
verify_checkout(path, name)
|
60
60
|
git.push_to_remote(path, name)
|
61
61
|
end
|
62
|
+
|
63
|
+
if FileOperator.definitely_exists?("#{path}/.bigkeeper/module.cache")
|
64
|
+
Logger.error(%Q('#{name}' has '.bigkeeper/module.cache' cache path, you should fix it manually...))
|
65
|
+
end
|
62
66
|
end
|
63
67
|
|
64
68
|
def verify_home_branch(path, branch_name, type)
|
@@ -93,6 +97,19 @@ module BigKeeper
|
|
93
97
|
end
|
94
98
|
end
|
95
99
|
|
100
|
+
def current_branch_type(path)
|
101
|
+
branch_name = GitOperator.new.current_branch(path)
|
102
|
+
if branch_name =~ /^feature\/S*/
|
103
|
+
GitflowType::FEATURE
|
104
|
+
elsif branch_name =~ /^hotfix\/S*/
|
105
|
+
GitflowType::HOTFIX
|
106
|
+
elsif branch_name =~ /^release\/S*/
|
107
|
+
GitflowType::RELEASE
|
108
|
+
else
|
109
|
+
GitflowType::FEATURE
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
96
113
|
def branchs_with_type(path, type)
|
97
114
|
branchs = []
|
98
115
|
Dir.chdir(path) do
|
@@ -69,18 +69,27 @@ module BigKeeper
|
|
69
69
|
verify_module(path, user, module_name, home_branch_name, type)
|
70
70
|
end
|
71
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
|
+
|
72
82
|
def publish(path, user, module_name, home_branch_name, type)
|
73
83
|
Logger.highlight("Publish branch '#{home_branch_name}' for module '#{module_name}'...")
|
74
84
|
|
75
|
-
|
85
|
+
DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::PUBLISH)
|
76
86
|
|
77
87
|
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
78
88
|
GitService.new.verify_push(module_full_path, "publish branch #{home_branch_name}", home_branch_name, module_name)
|
79
|
-
GitService.new.verify_rebase(module_full_path, GitflowType.base_branch(type), module_name)
|
80
89
|
|
81
90
|
`open #{BigkeeperParser.module_pulls(module_name)}`
|
82
91
|
|
83
|
-
ModuleCacheOperator.new(path).
|
92
|
+
ModuleCacheOperator.new(path).del_git_module(module_name)
|
84
93
|
end
|
85
94
|
|
86
95
|
def finish(path, user, module_name, home_branch_name, type)
|
@@ -88,31 +97,25 @@ module BigKeeper
|
|
88
97
|
|
89
98
|
verify_module(path, user, module_name, home_branch_name, type)
|
90
99
|
|
100
|
+
DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::FINISH)
|
101
|
+
|
91
102
|
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
|
92
103
|
GitService.new.verify_push(module_full_path, "finish branch #{home_branch_name}", home_branch_name, module_name)
|
93
104
|
|
94
|
-
|
95
|
-
|
96
|
-
DepService.dep_operator(path, user).update_module_config(
|
97
|
-
module_name,
|
98
|
-
ModuleType::GIT,
|
99
|
-
GitInfo.new(module_git, GitType::BRANCH, home_branch_name))
|
100
|
-
|
101
|
-
ModuleCacheOperator.new(path).add_branch_module(module_name)
|
105
|
+
ModuleCacheOperator.new(path).add_git_module(module_name)
|
106
|
+
ModuleCacheOperator.new(path).del_path_module(module_name)
|
102
107
|
end
|
103
108
|
|
104
109
|
def add(path, user, module_name, name, type)
|
105
110
|
home_branch_name = "#{GitflowType.name(type)}/#{name}"
|
106
111
|
Logger.highlight("Add branch '#{home_branch_name}' for module '#{module_name}'...")
|
107
112
|
|
108
|
-
|
109
113
|
verify_module(path, user, module_name, home_branch_name, type)
|
110
114
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
module_path)
|
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)
|
116
119
|
|
117
120
|
ModuleCacheOperator.new(path).add_path_module(module_name)
|
118
121
|
end
|
@@ -122,20 +125,28 @@ module BigKeeper
|
|
122
125
|
|
123
126
|
Logger.highlight("Delete branch '#{home_branch_name}' for module '#{module_name}'...")
|
124
127
|
|
125
|
-
|
126
|
-
|
127
|
-
StashService.new.stash(module_full_path, home_branch_name, module_name)
|
128
|
+
module_git = BigkeeperParser.module_git(module_name)
|
129
|
+
DepService.dep_operator(path, user).update_module_config(module_name, ModuleOperateType::DELETE)
|
128
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)
|
129
135
|
GitOperator.new.checkout(module_full_path, GitflowType.base_branch(type))
|
130
|
-
# GitOperator.new.del(module_full_path, home_branch_name)
|
131
|
-
|
132
|
-
module_git = BigkeeperParser.module_git(module_name)
|
133
|
-
DepService.dep_operator(path, user).update_module_config(
|
134
|
-
module_name,
|
135
|
-
ModuleType::GIT,
|
136
|
-
GitInfo.new(module_git, GitType::BRANCH, GitflowType.base_branch(type)))
|
137
136
|
|
138
137
|
ModuleCacheOperator.new(path).del_path_module(module_name)
|
139
138
|
end
|
139
|
+
|
140
|
+
def list(path, user, module_path)
|
141
|
+
branches_name = []
|
142
|
+
IO.popen("cd #{path}; git branch -a") do |io|
|
143
|
+
io.each do |line|
|
144
|
+
branches_name << line.strip if line.include? 'feature'
|
145
|
+
end
|
146
|
+
end
|
147
|
+
branches_name
|
148
|
+
end
|
149
|
+
|
150
|
+
private :verify_module
|
140
151
|
end
|
141
152
|
end
|
@@ -164,9 +164,12 @@ module BigKeeper
|
|
164
164
|
end
|
165
165
|
|
166
166
|
def self.verify_modules(modules)
|
167
|
+
modules = [] unless modules
|
168
|
+
modules = modules.uniq
|
167
169
|
modules.each do |item|
|
168
170
|
Logger.error("Can not find module #{item} in Bigkeeper file") unless @@config[:modules][item]
|
169
171
|
end
|
172
|
+
modules
|
170
173
|
end
|
171
174
|
|
172
175
|
def self.module_names
|
@@ -26,7 +26,6 @@ module BigKeeper
|
|
26
26
|
class ModuleCacheOperator
|
27
27
|
def initialize(path)
|
28
28
|
@cache_path = File.expand_path("#{path}/.bigkeeper")
|
29
|
-
@modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "current" => []}}
|
30
29
|
|
31
30
|
FileUtils.mkdir_p(@cache_path) unless File.exist?(@cache_path)
|
32
31
|
|
@@ -34,6 +33,8 @@ module BigKeeper
|
|
34
33
|
file = File.open("#{@cache_path}/module.cache", 'r')
|
35
34
|
@modules = JSON.load(file.read())
|
36
35
|
file.close
|
36
|
+
else
|
37
|
+
@modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "add" => [], "del" => [], "current" => []}}
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -41,10 +42,22 @@ module BigKeeper
|
|
41
42
|
@modules["path"]["all"]
|
42
43
|
end
|
43
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
|
+
|
44
53
|
def current_path_modules
|
45
54
|
@modules["path"]["current"]
|
46
55
|
end
|
47
56
|
|
57
|
+
def remain_path_modules
|
58
|
+
@modules["path"]["all"] - @modules["path"]["current"]
|
59
|
+
end
|
60
|
+
|
48
61
|
def all_git_modules
|
49
62
|
@modules["git"]["all"]
|
50
63
|
end
|
@@ -53,35 +66,39 @@ module BigKeeper
|
|
53
66
|
@modules["git"]["current"]
|
54
67
|
end
|
55
68
|
|
56
|
-
def
|
57
|
-
@modules["
|
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
|
58
77
|
cache_modules
|
59
78
|
end
|
60
79
|
|
61
80
|
def cache_git_modules(modules)
|
62
|
-
@modules["git"]["all"] = modules
|
81
|
+
@modules["git"]["all"] = modules.uniq
|
63
82
|
cache_modules
|
64
83
|
end
|
65
84
|
|
66
|
-
def
|
67
|
-
@modules["
|
68
|
-
@modules["git"]["current"] << module_name
|
85
|
+
def add_git_module(module_name)
|
86
|
+
@modules["git"]["current"] << module_name unless @modules["git"]["current"].include?(module_name)
|
69
87
|
cache_modules
|
70
88
|
end
|
71
89
|
|
72
|
-
def
|
73
|
-
@modules["git"]["current"].delete(module_name)
|
90
|
+
def del_git_module(module_name)
|
91
|
+
@modules["git"]["current"].delete(module_name) if @modules["git"]["current"].include?(module_name)
|
74
92
|
cache_modules
|
75
93
|
end
|
76
94
|
|
77
95
|
def add_path_module(module_name)
|
78
|
-
@modules["
|
79
|
-
@modules["path"]["current"] << module_name
|
96
|
+
@modules["path"]["current"] << module_name unless @modules["path"]["current"].include?(module_name)
|
80
97
|
cache_modules
|
81
98
|
end
|
82
99
|
|
83
100
|
def del_path_module(module_name)
|
84
|
-
@modules["path"]["current"].delete(module_name)
|
101
|
+
@modules["path"]["current"].delete(module_name) if @modules["path"]["current"].include?(module_name)
|
85
102
|
cache_modules
|
86
103
|
end
|
87
104
|
|
@@ -13,7 +13,7 @@ module BigKeeper
|
|
13
13
|
has_branch = false
|
14
14
|
IO.popen("cd #{path}; git branch -r") do |io|
|
15
15
|
io.each do |line|
|
16
|
-
has_branch = true if line
|
16
|
+
has_branch = true if line =~ /([\s\S]*)#{branch_name}$/
|
17
17
|
end
|
18
18
|
end
|
19
19
|
has_branch
|
@@ -23,7 +23,7 @@ module BigKeeper
|
|
23
23
|
has_branch = false
|
24
24
|
IO.popen("cd #{path}; git branch") do |io|
|
25
25
|
io.each do |line|
|
26
|
-
has_branch = true if line
|
26
|
+
has_branch = true if line =~ /([\s\S]*)#{branch_name}$/
|
27
27
|
end
|
28
28
|
end
|
29
29
|
has_branch
|
@@ -33,7 +33,7 @@ module BigKeeper
|
|
33
33
|
has_branch = false
|
34
34
|
IO.popen("cd #{path}; git branch -a") do |io|
|
35
35
|
io.each do |line|
|
36
|
-
has_branch = true if line
|
36
|
+
has_branch = true if line =~ /([\s\S]*)#{branch_name}$/
|
37
37
|
end
|
38
38
|
end
|
39
39
|
has_branch
|
@@ -88,7 +88,7 @@ module BigKeeper
|
|
88
88
|
|
89
89
|
def has_commits(path, branch_name)
|
90
90
|
has_commits = false
|
91
|
-
IO.popen("cd #{path}; git log
|
91
|
+
IO.popen("cd #{path}; git log #{branch_name} --not --remotes") do |io|
|
92
92
|
io.each do |line|
|
93
93
|
has_commits = true if line.include? branch_name
|
94
94
|
end
|
@@ -4,141 +4,173 @@ module BigKeeper
|
|
4
4
|
# Operator for podfile
|
5
5
|
class GradleOperator
|
6
6
|
def initialize(path)
|
7
|
-
@path =
|
7
|
+
@path = path
|
8
8
|
end
|
9
9
|
|
10
10
|
def backup
|
11
11
|
cache_operator = CacheOperator.new(@path)
|
12
|
+
|
12
13
|
cache_operator.save('settings.gradle')
|
14
|
+
|
13
15
|
Dir.glob("#{@path}/*/build.gradle").each do |build_gradle_file_path|
|
14
16
|
build_gradle_file = build_gradle_file_path.gsub!(/#{@path}/, '')
|
15
17
|
cache_operator.save(build_gradle_file)
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
|
-
def recover
|
21
|
+
def recover(settings_config, build_config)
|
20
22
|
cache_operator = CacheOperator.new(@path)
|
21
|
-
|
23
|
+
|
24
|
+
cache_operator.load('settings.gradle') if settings_config
|
25
|
+
|
26
|
+
if build_config
|
27
|
+
Dir.glob("#{@path}/*/build.gradle").each do |build_gradle_file_path|
|
28
|
+
build_gradle_file = build_gradle_file_path.gsub!(/#{@path}/, '')
|
29
|
+
cache_operator.load(build_gradle_file)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
22
33
|
cache_operator.clean
|
23
34
|
end
|
24
35
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
36
|
+
def update_settings_config(current_module_name, modules, module_operate_type, user)
|
37
|
+
return if modules.empty?
|
38
|
+
|
39
|
+
if ModuleOperateType::ADD == module_operate_type
|
40
|
+
modules.each do |module_name|
|
41
|
+
next if current_module_name == module_name
|
42
|
+
|
43
|
+
File.open("#{@path}/settings.gradle", 'a') do |file|
|
31
44
|
file.puts "\r\ninclude ':module:#{module_name.downcase}'\r\n"
|
32
45
|
file.puts "project(':module:#{module_name.downcase}')." \
|
33
46
|
"projectDir = new File(rootProject.projectDir," \
|
34
47
|
"'#{BigkeeperParser.module_path(user, module_name)}/#{module_name.downcase}-lib')\r\n"
|
35
48
|
end
|
36
49
|
end
|
37
|
-
|
50
|
+
else
|
51
|
+
modules.each do |module_name|
|
52
|
+
next if current_module_name == module_name
|
53
|
+
temp_file = Tempfile.new('.settings.gradle.tmp')
|
54
|
+
begin
|
55
|
+
File.open("#{@path}/settings.gradle", 'r') do |file|
|
56
|
+
file.each_line do |line|
|
57
|
+
unless line =~ /(\s*)include(\s*)('|")(\S*):#{module_name.downcase}('|")(\S*)/ ||
|
58
|
+
line =~ /(\s*)project\(('|")(\S*):#{module_name.downcase}('|")\).(\S*)/
|
59
|
+
temp_file.puts(line)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
temp_file.close
|
64
|
+
FileUtils.mv(temp_file.path, "#{@path}/settings.gradle")
|
65
|
+
ensure
|
66
|
+
temp_file.close
|
67
|
+
temp_file.unlink
|
68
|
+
end
|
69
|
+
end
|
38
70
|
end
|
39
71
|
end
|
40
72
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
version_flag =
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
73
|
+
def update_build_config(current_module_name, modules, module_operate_type)
|
74
|
+
return if modules.empty?
|
75
|
+
|
76
|
+
Dir.glob("#{@path}/*/build.gradle").each do |file_path|
|
77
|
+
modules.each do |module_name|
|
78
|
+
next if current_module_name == module_name
|
79
|
+
|
80
|
+
temp_file = Tempfile.new('.build.gradle.tmp')
|
81
|
+
begin
|
82
|
+
version_flag = false
|
83
|
+
version_index = 0
|
84
|
+
|
85
|
+
File.open(file_path, 'r') do |file|
|
86
|
+
file.each_line do |line|
|
87
|
+
new_line, version_index, version_flag = generate_build_config(
|
88
|
+
line,
|
89
|
+
module_name,
|
90
|
+
module_operate_type,
|
91
|
+
version_index,
|
92
|
+
version_flag)
|
93
|
+
|
94
|
+
temp_file.puts(new_line)
|
60
95
|
end
|
61
96
|
end
|
97
|
+
temp_file.close
|
98
|
+
FileUtils.mv(temp_file.path, file_path)
|
99
|
+
ensure
|
100
|
+
temp_file.close
|
101
|
+
temp_file.unlink
|
62
102
|
end
|
63
|
-
temp_file.close
|
64
|
-
FileUtils.mv(temp_file.path, file)
|
65
|
-
ensure
|
66
|
-
temp_file.close
|
67
|
-
temp_file.unlink
|
68
103
|
end
|
69
104
|
end
|
70
105
|
end
|
71
106
|
|
72
|
-
def
|
73
|
-
|
107
|
+
def generate_build_config(line, module_name, module_operate_type, version_index, version_flag)
|
108
|
+
new_line = line
|
109
|
+
|
110
|
+
version_flag = true if line.downcase.include? 'modifypom'
|
111
|
+
if version_flag
|
112
|
+
version_index += 1 if line.include? '{'
|
113
|
+
version_index -= 1 if line.include? '}'
|
114
|
+
|
115
|
+
version_flag = false if 0 == version_flag
|
116
|
+
|
117
|
+
new_line = generate_version_config(line, module_name, module_operate_type)
|
118
|
+
else
|
119
|
+
new_line = generate_compile_config(line, module_name, module_operate_type)
|
120
|
+
end
|
121
|
+
|
122
|
+
[new_line, version_index, version_flag]
|
123
|
+
end
|
124
|
+
|
125
|
+
def generate_version_config(line, module_name, module_operate_type)
|
126
|
+
if ModuleOperateType::FINISH == module_operate_type || ModuleOperateType::PUBLISH == module_operate_type
|
74
127
|
branch_name = GitOperator.new.current_branch(@path)
|
75
128
|
full_name = ''
|
76
129
|
|
77
130
|
# Get version part of source.addition
|
78
|
-
if
|
131
|
+
if ModuleOperateType::PUBLISH == module_operate_type
|
79
132
|
full_name = branch_name.sub(/([\s\S]*)\/(\d+.\d+.\d+)_([\s\S]*)/){ $2 }
|
80
133
|
else
|
81
134
|
full_name = branch_name.sub(/([\s\S]*)\/([\s\S]*)/){ $2 }
|
82
135
|
end
|
136
|
+
|
83
137
|
line.sub(/(\s*)version ('|")(\S*)('|")([\s\S]*)/){
|
84
138
|
"#{$1}version '#{full_name}'#{$5}"
|
85
139
|
}
|
86
|
-
elsif ModuleType::SPEC == module_type
|
87
|
-
line.sub(/(\s*)version ('|")(\S*)('|")([\s\S]*)/){
|
88
|
-
"#{$1}version '#{source}'#{$5}"
|
89
|
-
}
|
90
140
|
else
|
91
141
|
line
|
92
142
|
end
|
93
143
|
end
|
94
144
|
|
95
|
-
def
|
96
|
-
|
97
|
-
|
98
|
-
File.open(file, 'r') do |file|
|
99
|
-
file.each_line do |line|
|
100
|
-
if line =~ /(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/
|
101
|
-
prefix = line.sub(/(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
|
102
|
-
$4
|
103
|
-
}
|
104
|
-
break
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
break unless prefix.empty?
|
109
|
-
end
|
110
|
-
|
111
|
-
prefix.chop
|
112
|
-
end
|
113
|
-
|
114
|
-
def generate_compile_config(line, module_name, module_type, source)
|
115
|
-
if ModuleType::PATH == module_type
|
116
|
-
line.sub(/(\s*)compile(\s*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
|
145
|
+
def generate_compile_config(line, module_name, module_operate_type)
|
146
|
+
if ModuleOperateType::ADD == module_operate_type
|
147
|
+
line.sub(/(\s*)compile(\s*)('|")(\S*):#{module_name.downcase}:(\S*)('|")(\S*)/){
|
117
148
|
"#{$1}compile project(':module:#{module_name.downcase}')"
|
118
149
|
}
|
119
|
-
elsif
|
150
|
+
elsif ModuleOperateType::DELETE == module_operate_type
|
151
|
+
line.sub(/(\s*)([\s\S]*)('|")(\S*):#{module_name.downcase}:(\S*)('|")(\S*)/){
|
152
|
+
origin_config_of_module = origin_config_of_module(module_name)
|
153
|
+
if origin_config_of_module.empty?
|
154
|
+
line
|
155
|
+
else
|
156
|
+
origin_config_of_module
|
157
|
+
end
|
158
|
+
}
|
159
|
+
elsif ModuleOperateType::FINISH == module_operate_type || ModuleOperateType::PUBLISH == module_operate_type
|
120
160
|
branch_name = GitOperator.new.current_branch(@path)
|
121
161
|
full_name = ''
|
122
162
|
|
123
163
|
# Get version part of source.addition
|
124
|
-
if
|
164
|
+
if ModuleOperateType::PUBLISH == module_operate_type
|
125
165
|
full_name = branch_name.sub(/([\s\S]*)\/(\d+.\d+.\d+)_([\s\S]*)/){ $2 }
|
126
166
|
else
|
127
167
|
full_name = branch_name.sub(/([\s\S]*)\/([\s\S]*)/){ $2 }
|
128
168
|
end
|
129
|
-
line.sub(/(\s*)([\s\S]*)('|")(\S*)
|
130
|
-
if $2.include? '
|
131
|
-
"#{$1}moduleCompile '#{prefix_of_module(module_name)}
|
132
|
-
else
|
133
|
-
"#{$1}compile '#{prefix_of_module(module_name)}#{module_name.downcase}:#{full_name}-SNAPSHOT'"
|
134
|
-
end
|
135
|
-
}
|
136
|
-
elsif ModuleType::SPEC == module_type
|
137
|
-
line.sub(/(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
|
138
|
-
if $2.include? 'moduleCompile'
|
139
|
-
"#{$1}moduleCompile '#{prefix_of_module(module_name)}#{module_name.downcase}:#{source}'"
|
169
|
+
line.sub(/(\s*)([\s\S]*)('|")(\S*):#{module_name.downcase}(:\S*)*('|")(\S*)/){
|
170
|
+
if $2.downcase.include? 'modulecompile'
|
171
|
+
"#{$1}moduleCompile '#{prefix_of_module(module_name)}:#{module_name.downcase}:#{full_name}-SNAPSHOT'"
|
140
172
|
else
|
141
|
-
"#{$1}compile '#{prefix_of_module(module_name)}
|
173
|
+
"#{$1}compile '#{prefix_of_module(module_name)}:#{module_name.downcase}:#{full_name}-SNAPSHOT'"
|
142
174
|
end
|
143
175
|
}
|
144
176
|
else
|
@@ -146,6 +178,32 @@ module BigKeeper
|
|
146
178
|
end
|
147
179
|
end
|
148
180
|
|
149
|
-
|
181
|
+
def origin_config_of_module(module_name)
|
182
|
+
origin_config = ''
|
183
|
+
|
184
|
+
Dir.glob("#{@path}/.bigkeeper/*/build.gradle").each do |file|
|
185
|
+
File.open(file, 'r') do |file|
|
186
|
+
file.each_line do |line|
|
187
|
+
if line =~ /(\s*)([\s\S]*)('|")(\S*):#{module_name.downcase}:(\S*)('|")(\S*)/
|
188
|
+
origin_config = line
|
189
|
+
break
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
break unless origin_config.empty?
|
194
|
+
end
|
195
|
+
|
196
|
+
origin_config.chop
|
197
|
+
end
|
198
|
+
|
199
|
+
def prefix_of_module(module_name)
|
200
|
+
origin_config = origin_config_of_module(module_name)
|
201
|
+
prefix = origin_config.sub(/(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
|
202
|
+
$4
|
203
|
+
}
|
204
|
+
prefix.chop
|
205
|
+
end
|
206
|
+
|
207
|
+
private :generate_build_config, :generate_compile_config, :generate_version_config, :origin_config_of_module, :prefix_of_module
|
150
208
|
end
|
151
209
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'big_keeper/util/logger'
|
2
|
+
|
3
|
+
module BigKeeper
|
4
|
+
class ListGenerator
|
5
|
+
def self.generate(file_path,branches_name)
|
6
|
+
module_branches_dic = {}
|
7
|
+
home_name = BigkeeperParser.home_name
|
8
|
+
File.open(file_path, 'r') do |file|
|
9
|
+
file.each_line do |line|
|
10
|
+
if /=>/ =~ line.delete('{}"')
|
11
|
+
module_branches_dic[$~.pre_match] = $~.post_match.delete('[]"').split(',')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
branches_name.each do |branch_name|
|
17
|
+
Logger.highlight(" #{home_name} - #{branch_name} ")
|
18
|
+
module_branches_dic.keys.each do |module_name|
|
19
|
+
module_branches_dic[module_name].each do |module_branch|
|
20
|
+
if module_branch.include?(branch_name.strip.delete('*'))
|
21
|
+
Logger.default(" |_ _ _ #{module_name} - #{branch_name}")
|
22
|
+
break
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/big_keeper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigkeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mmoaay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -227,6 +227,7 @@ files:
|
|
227
227
|
- lib/big_keeper/command/feature&hotfix.rb
|
228
228
|
- lib/big_keeper/command/feature&hotfix/delete.rb
|
229
229
|
- lib/big_keeper/command/feature&hotfix/finish.rb
|
230
|
+
- lib/big_keeper/command/feature&hotfix/list.rb
|
230
231
|
- lib/big_keeper/command/feature&hotfix/publish.rb
|
231
232
|
- lib/big_keeper/command/feature&hotfix/pull.rb
|
232
233
|
- lib/big_keeper/command/feature&hotfix/push.rb
|
@@ -257,6 +258,7 @@ files:
|
|
257
258
|
- lib/big_keeper/util/gitflow_operator.rb
|
258
259
|
- lib/big_keeper/util/gradle_operator.rb
|
259
260
|
- lib/big_keeper/util/info_plist_operator.rb
|
261
|
+
- lib/big_keeper/util/list_generator.rb
|
260
262
|
- lib/big_keeper/util/logger.rb
|
261
263
|
- lib/big_keeper/util/pod_operator.rb
|
262
264
|
- lib/big_keeper/util/podfile_detector.rb
|