Module: BigKeeper
- Defined in:
- lib/big_keeper/util/bigkeeper_parser.rb,
lib/big_keeper.rb,
lib/big_keeper/version.rb,
lib/big_keeper/util/logger.rb,
lib/big_keeper/util/git_operator.rb,
lib/big_keeper/util/pod_operator.rb,
lib/big_keeper/model/gitflow_type.rb,
lib/big_keeper/model/operate_type.rb,
lib/big_keeper/model/podfile_type.rb,
lib/big_keeper/model/podfile_model.rb,
lib/big_keeper/service/git_service.rb,
lib/big_keeper/command/release/home.rb,
lib/big_keeper/service/stash_service.rb,
lib/big_keeper/util/gitflow_operator.rb,
lib/big_keeper/util/podfile_detector.rb,
lib/big_keeper/util/podfile_operator.rb,
lib/big_keeper/command/release/module.rb,
lib/big_keeper/service/module_service.rb,
lib/big_keeper/command/pod/podfile_lock.rb,
lib/big_keeper/util/info_plist_operator.rb,
lib/big_keeper/command/feature&hotfix/pull.rb,
lib/big_keeper/command/feature&hotfix/push.rb,
lib/big_keeper/command/feature&hotfix/start.rb,
lib/big_keeper/command/feature&hotfix/delete.rb,
lib/big_keeper/command/feature&hotfix/finish.rb,
lib/big_keeper/command/feature&hotfix/switch.rb,
lib/big_keeper/command/feature&hotfix/update.rb
Overview
Defined Under Namespace
Modules: GitType, GitflowType, ModuleType, OperateType
Classes: BigkeeperParser, GitInfo, GitOperator, GitService, GitflowOperator, InfoPlistOperator, Logger, ModuleService, PodOperator, PodfileDetector, PodfileOperator, Podfile_Modle, StashService
Constant Summary
collapse
- VERSION =
"0.7.1"
- DEFAULT_LOG =
1
- HIGHLIGHT_LOG =
2
- ERROR_LOG =
3
- WARNING_LOG =
4
Class Method Summary
collapse
-
.delete(path, user, name, type) ⇒ Object
-
.finish(path, user, type) ⇒ Object
-
.home(name, params) ⇒ Object
-
.modules ⇒ Object
-
.pod(name, params) ⇒ Object
-
.podfile_detect(path) ⇒ Object
-
.podfile_lock(path) ⇒ Object
-
.pull(path, user, type) ⇒ Object
-
.push(path, user, comment, type) ⇒ Object
-
.release_home_finish(path, version) ⇒ Object
-
.release_home_start(path, version, user) ⇒ Object
-
.release_module_finish(path, version, user, module_name) ⇒ Object
-
.release_module_start(path, version, user, module_name) ⇒ Object
-
.source(name) ⇒ Object
-
.start(path, version, user, name, modules, type) ⇒ Object
-
.switch_to(path, version, user, name, type) ⇒ Object
-
.update(path, user, modules, type) ⇒ Object
-
.user(name) ⇒ Object
-
.version(name) ⇒ Object
Class Method Details
.delete(path, user, name, type) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/big_keeper/command/feature&hotfix/delete.rb', line 16
def self.delete(path, user, name, type)
begin
BigkeeperParser.parse("#{path}/Bigkeeper")
branch_name = "#{GitflowType.name(type)}/#{name}"
modules = BigkeeperParser.module_names
modules.each do |module_name|
module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
GitService.new.verify_del(module_full_path, branch_name, module_name, type)
end
GitService.new.verify_del(path, branch_name, 'Home', type)
ensure
end
end
|
.finish(path, user, type) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/big_keeper/command/feature&hotfix/finish.rb', line 13
def self.finish(path, user, type)
begin
BigkeeperParser.parse("#{path}/Bigkeeper")
modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
BigkeeperParser.module_names, ModuleType::PATH)
branch_name = GitOperator.new.current_branch(path)
Logger.error("Not a #{GitflowType.name(type)} branch, exit.") unless branch_name.include? GitflowType.name(type)
modules.each do |module_name|
ModuleService.new.finish(path, user, module_name, branch_name, type)
end
Logger.highlight("Finish branch '#{branch_name}' for 'Home'")
PodOperator.pod_install(path)
modules.each do |module_name|
module_git = BigkeeperParser.module_git(module_name)
PodfileOperator.new.find_and_replace("#{path}/Podfile",
module_name,
ModuleType::GIT,
GitInfo.new(module_git, GitType::BRANCH, GitflowType.base_branch(type)))
end
GitService.new.verify_push(path, "finish branch #{branch_name}", branch_name, 'Home')
GitService.new.verify_rebase(path, GitflowType.base_branch(type), 'Home')
`open #{BigkeeperParser.home_pulls()}`
ensure
end
end
|
.home(name, params) ⇒ Object
14
15
16
|
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 14
def self.home(name, params)
BigkeeperParser.parse_home(name, params)
end
|
.modules ⇒ Object
22
23
24
25
|
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 22
def self.modules
BigkeeperParser.parse_modules
yield if block_given?
end
|
.pod(name, params) ⇒ Object
18
19
20
|
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 18
def self.pod(name, params)
BigkeeperParser.parse_pod(name, params)
end
|
.podfile_detect(path) ⇒ Object
.podfile_lock(path) ⇒ Object
.pull(path, user, type) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/big_keeper/command/feature&hotfix/pull.rb', line 4
def self.pull(path, user, type)
begin
BigkeeperParser.parse("#{path}/Bigkeeper")
branch_name = GitOperator.new.current_branch(path)
Logger.error("Not a #{GitflowType.name(type)} branch, exit.") unless branch_name.include? GitflowType.name(type)
modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
BigkeeperParser.module_names, ModuleType::PATH)
modules.each do |module_name|
ModuleService.new.pull(path, user, module_name, branch_name, type)
end
Logger.highlight("Pull branch '#{branch_name}' for 'Home'...")
GitOperator.new.pull(path)
ensure
end
end
|
.push(path, user, comment, type) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/big_keeper/command/feature&hotfix/push.rb', line 5
def self.push(path, user, , type)
begin
BigkeeperParser.parse("#{path}/Bigkeeper")
branch_name = GitOperator.new.current_branch(path)
Logger.error("Not a #{GitflowType.name(type)} branch, exit.") unless branch_name.include? GitflowType.name(type)
modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
BigkeeperParser.module_names, ModuleType::PATH)
modules.each do |module_name|
ModuleService.new.push(path, user, module_name, branch_name, type, )
end
Logger.highlight("Push branch '#{branch_name}' for 'Home'...")
GitService.new.verify_push(path, , branch_name, 'Home')
ensure
end
end
|
.release_home_finish(path, version) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/big_keeper/command/release/home.rb', line 14
def self.release_home_finish(path, version)
Dir.chdir(path) do
if GitOperator.new.has_branch(path, "release/#{version}")
if GitOperator.new.current_branch(path) == "release/#{version}"
GitOperator.new.commit(path, "release: V #{version}")
GitOperator.new.push_to_remote(path, "release/#{version}")
GitflowOperator.new.finish_release(path, version)
if GitOperator.new.current_branch(path) == "master"
GitOperator.new.tag(path, version)
else
GitOperator.new.checkout(path, "master")
GitOperator.new.tag(path, version)
end
else
raise Logger.error("Not in release branch, please check your branches.")
end
else
raise Logger.error("Not has release branch, please use release start first.")
end
end
end
|
.release_home_start(path, version, user) ⇒ Object
.release_module_finish(path, version, user, module_name) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/big_keeper/command/release/module.rb', line 20
def self.release_module_finish(path, version, user, module_name)
BigkeeperParser.parse("#{path}/Bigkeeper")
module_path = self.get_module_path_default(path, user, module_name)
Logger.error("current branch has changed") unless GitOperator.new.has_changes(module_path)
if GitOperator.new.current_branch(module_path) != "master"
current_name = GitOperator.new.current_branch(module_path)
GitOperator.new.checkout(module_path, "master")
Logger.highlight("Push branch '#{current_name}' for '#{module_name}'...")
GitService.new.verify_push(module_path, "finish #{GitflowType.name(GitflowType::RELEASE)} #{current_name}", "master", "#{module_name}")
end
return
Dir.chdir(module_path) do
Logger.highlight(%Q(Rebase develop to master))
PodfileOperator.new.podspec_change(%Q(#{module_path}/#{module_name}.podspec), version, module_name)
GitService.new.verify_rebase(module_path, 'develop', "#{module_name}")
GitOperator.new.verify_push(module_path, "finish rebase develop to master", "master", "#{module_name}")
GitOperator.new.tag(module_path, version)
Logger.highlight(%Q(Start Pod repo push #{module_name}))
IO.popen("pod repo push #{module_name} #{module_name}.podspec --allow-warnings --sources=#{BigkeeperParser::sourcemodule_path}") do |io|
io.each do |line|
has_error = true if line.include? "ERROR"
end
end
if has_error
Logger.error("Pod repo push in '#{module_name}'")
return
end
Logger.highlight(%Q(Success release #{module_name} V#{version}))
end
end
|
.release_module_start(path, version, user, module_name) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/big_keeper/command/release/module.rb', line 10
def self.release_module_start(path, version, user, module_name)
BigkeeperParser.parse("#{path}/Bigkeeper")
Dir.chdir(path) do
git_info = GitInfo.new(BigkeeperParser::home_git, GitType::TAG, version)
module_path = self.get_module_path_default(path, user, module_name)
start_module_release(module_path, version, module_name, git_info, user)
end
end
|
.start(path, version, user, name, modules, type) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/big_keeper/command/feature&hotfix/start.rb', line 16
def self.start(path, version, user, name, modules, type)
begin
BigkeeperParser.parse("#{path}/Bigkeeper")
version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
full_name = "#{version}_#{user}_#{name}"
branch_name = "#{GitflowType.name(type)}/#{full_name}"
GitService.new.verify_home_branch(path, branch_name, OperateType::START)
stash_modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
BigkeeperParser.module_names, ModuleType::PATH)
StashService.new.stash_all(path, branch_name, user, stash_modules)
if modules
BigkeeperParser.verify_modules(modules)
else
modules = BigkeeperParser.module_names
end
Logger.highlight("Add branch '#{branch_name}' for 'Home'...")
GitService.new.start(path, full_name, type)
modules.each do |module_name|
ModuleService.new.add(path, user, module_name, full_name, type)
end
PodOperator.pod_install(path)
GitService.new.verify_push(path, "init #{GitflowType.name(type)} #{full_name}", branch_name, 'Home')
`open #{path}/*.xcworkspace`
ensure
end
end
|
.switch_to(path, version, user, name, type) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/big_keeper/command/feature&hotfix/switch.rb', line 7
def self.switch_to(path, version, user, name, type)
begin
BigkeeperParser.parse("#{path}/Bigkeeper")
version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
full_name = "#{version}_#{user}_#{name}"
branch_name = "#{GitflowType.name(type)}/#{full_name}"
GitService.new.verify_home_branch(path, branch_name, OperateType::SWITCH)
stash_modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
BigkeeperParser.module_names, ModuleType::PATH)
StashService.new.stash_all(path, branch_name, user, stash_modules)
GitOperator.new.checkout(path, branch_name)
GitOperator.new.pull(path)
StashService.new.pop_stash(path, branch_name, 'Home')
modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
BigkeeperParser.module_names, ModuleType::PATH)
modules.each do |module_name|
ModuleService.new.switch_to(path, user, module_name, branch_name, type)
end
PodOperator.pod_install(path)
`open #{path}/*.xcworkspace`
ensure
end
end
|
.update(path, user, modules, type) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/big_keeper/command/feature&hotfix/update.rb', line 16
def self.update(path, user, modules, type)
begin
BigkeeperParser.parse("#{path}/Bigkeeper")
branch_name = GitOperator.new.current_branch(path)
Logger.error("Not a #{GitflowType.name(type)} branch, exit.") unless branch_name.include? GitflowType.name(type)
full_name = branch_name.gsub(/#{GitflowType.name(type)}\//, '')
current_modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
BigkeeperParser.module_names, ModuleType::PATH)
if modules
BigkeeperParser.verify_modules(modules)
else
modules = BigkeeperParser.module_names
end
Logger.highlight("Start to update modules for branch '#{branch_name}'...")
add_modules = modules - current_modules
del_modules = current_modules - modules
if add_modules.empty? and del_modules.empty?
Logger.default("There is nothing changed with modules #{modules}.")
else
add_modules.each do |module_name|
ModuleService.new.add(path, user, module_name, full_name, type)
end
del_modules.each do |module_name|
ModuleService.new.del(path, user, module_name, full_name, type)
end
PodOperator.pod_install(path)
`open #{path}/*.xcworkspace`
end
ensure
end
end
|
.user(name) ⇒ Object
9
10
11
12
|
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 9
def self.user(name)
BigkeeperParser.parse_user(name)
yield if block_given?
end
|