Module: BigKeeper
- Defined in:
- lib/big_keeper/util/bigkeeper_parser.rb,
lib/big_keeper.rb,
lib/big_keeper/version.rb,
lib/big_keeper/command/pod.rb,
lib/big_keeper/util/logger.rb,
lib/big_keeper/command/spec.rb,
lib/big_keeper/command/image.rb,
lib/big_keeper/command/release.rb,
lib/big_keeper/command/spec/add.rb,
lib/big_keeper/command/spec/list.rb,
lib/big_keeper/command/spec/sync.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/util/code_operator.rb,
lib/big_keeper/util/file_operator.rb,
lib/big_keeper/command/pod/podfile.rb,
lib/big_keeper/command/spec/delete.rb,
lib/big_keeper/command/spec/search.rb,
lib/big_keeper/dependency/dep_type.rb,
lib/big_keeper/model/library_model.rb,
lib/big_keeper/model/podfile_model.rb,
lib/big_keeper/service/git_service.rb,
lib/big_keeper/util/cache_operator.rb,
lib/big_keeper/util/list_generator.rb,
lib/big_keeper/util/podfile_module.rb,
lib/big_keeper/util/xcode_operator.rb,
lib/big_keeper/command/release/home.rb,
lib/big_keeper/command/spec/analyze.rb,
lib/big_keeper/util/gradle_operator.rb,
lib/big_keeper/util/verify_operator.rb,
lib/big_keeper/service/stash_service.rb,
lib/big_keeper/util/gitflow_operator.rb,
lib/big_keeper/util/leancloud_logger.rb,
lib/big_keeper/util/podfile_detector.rb,
lib/big_keeper/util/podfile_operator.rb,
lib/big_keeper/command/feature&hotfix.rb,
lib/big_keeper/command/release/module.rb,
lib/big_keeper/dependency/dep_service.rb,
lib/big_keeper/service/module_service.rb,
lib/big_keeper/dependency/dep_operator.rb,
lib/big_keeper/util/info_plist_operator.rb,
lib/big_keeper/command/feature&hotfix/list.rb,
lib/big_keeper/command/feature&hotfix/pull.rb,
lib/big_keeper/command/feature&hotfix/push.rb,
lib/big_keeper/dependency/dep_pod_operator.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/rebase.rb,
lib/big_keeper/command/feature&hotfix/switch.rb,
lib/big_keeper/command/feature&hotfix/update.rb,
lib/big_keeper/command/feature&hotfix/publish.rb,
lib/big_keeper/dependency/dep_gradle_operator.rb
Overview
Bigkeeper module
Defined Under Namespace
Modules: DepType, GitflowType, ModuleOperateType, OperateType Classes: BigkeeperParser, CacheOperator, DepGradleOperator, DepOperator, DepPodOperator, DepService, FileOperator, GitOperator, GitService, GitflowOperator, GradleOperator, InfoPlistOperator, LeanCloudLogger, LibraryModel, ListGenerator, Logger, ModuleCacheOperator, ModuleService, OCCodeOperator, PodOperator, PodfileDetector, PodfileModel, PodfileModuleDetector, PodfileOperator, StashService, VerifyOperator, XcodeOperator
Constant Summary collapse
- VERSION =
"3.1.2"
- DEFAULT_LOG =
1
- HIGHLIGHT_LOG =
2
- ERROR_LOG =
3
- WARNING_LOG =
4
Class Method Summary collapse
- .configs ⇒ Object
- .delete(path, user, name, type) ⇒ Object
- .feature_and_hotfix_command(type) ⇒ Object
- .finish(path, user, type) ⇒ Object
- .generate_list_with_option(options, file_path, version, home_branches) ⇒ Object
- .get_module_info(path, user, type, version, home_branches, is_print_log) ⇒ Object
- .home(name, params) ⇒ Object
- .image_command ⇒ Object
- .list(path, user, type, options) ⇒ Object
- .mod(name, params) ⇒ Object
- .modules ⇒ Object
- .param(key, value) ⇒ Object
- .pod_command ⇒ Object
- .podfile_detect(path) ⇒ Object
- .podfile_lock(path) ⇒ Object
- .podfile_modules_update(path) ⇒ Object
- .publish(path, user, type) ⇒ Object
- .pull(path, user, type) ⇒ Object
- .push(path, user, comment, type) ⇒ Object
- .rebase(path, user, type) ⇒ Object
- .release_command ⇒ Object
- .release_home_finish(path, version) ⇒ Object
- .release_home_start(path, version, user) ⇒ Object
-
.release_module_finish(path, version, user, module_name, spec) ⇒ Object
release finish.
- .release_module_start(path, version, user, module_name, ignore) ⇒ Object
- .source(name) ⇒ Object
- .spec_add ⇒ Object
- .spec_analyze(path, is_all, find_module_names) ⇒ Object
- .spec_command ⇒ Object
- .spec_delete ⇒ Object
- .spec_list(path, user, options) ⇒ Object
- .spec_search ⇒ Object
- .spec_sync(path, version, user, module_name) ⇒ Object
- .start(path, version, user, modules, type) ⇒ Object
- .switch_to(path, version, user, full_name, type) ⇒ Object
- .update(path, user, modules, type) ⇒ Object
- .user(name) ⇒ Object
- .version(name) ⇒ Object
Class Method Details
.configs ⇒ Object
33 34 35 36 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 33 def self.configs BigkeeperParser.parse_configs yield if block_given? end |
.delete(path, user, name, type) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/big_keeper/command/feature&hotfix/delete.rb', line 18 def self.delete(path, user, name, type) begin # Parse Bigkeeper file 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) if FileOperator.definitely_exists?(module_full_path) StashService.new.pop_stash(module_full_path, branch_name, module_name) GitService.new.verify_del(module_full_path, branch_name, module_name, type) end end StashService.new.pop_stash(path, branch_name, 'Home') GitService.new.verify_del(path, branch_name, 'Home', type) ensure end end |
.feature_and_hotfix_command(type) ⇒ Object
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/big_keeper/command/feature&hotfix.rb', line 14 def self.feature_and_hotfix_command(type) desc "Gitflow #{GitflowType.name(type)} operations" command GitflowType.command(type) do |c| c.desc "Start a new #{GitflowType.name(type)} with name for given modules and main project" c.command :start do |start| start.action do |, , args| path = File.([:path]) version = [:ver] user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/start") help_now!('user name is required') if user and user.empty? help_now!("#{GitflowType.name(type)} name is required") if args.length < 1 #name = args[0] #modules = args[(1...args.length)] if args.length > 1 modules = args[(0...args.length)] if args.length > 0 #start(path, version, user, name, modules, type) start(path, version, user, modules, type) end end c.desc "Update modules for the #{GitflowType.name(type)} with name" c.command :update do |update| update.action do |, , args| path = File.([:path]) user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/update") help_now!('user name is required') if user and user.empty? modules = args[(0...args.length)] if args.length > 0 update(path, user, modules, type) end end c.desc "Switch to the #{GitflowType.name(type)} with name" c.command :switch do |switch| switch.action do |, , args| path = File.([:path]) version = [:ver] user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/switch") help_now!('user name is required') if user and user.empty? help_now!("#{GitflowType.name(type)} name is required") if args.length < 1 name = args[0] switch_to(path, version, user, name, type) end end c.desc "Pull remote changes for current #{GitflowType.name(type)}" c.command :pull do |pull| pull.action do |, , args| path = File.([:path]) user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/pull") help_now!('user name is required') if user and user.empty? pull(path, user, type) end end c.desc "Push local changes to remote for current #{GitflowType.name(type)}" c.command :push do |push| push.action do |, , args| path = File.([:path]) user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/push") help_now!('user name is required') if user and user.empty? help_now!('comment message is required') if args.length < 1 help_now!(%Q(comment message should be wrappered with '' or "")) if args.length > 1 comment = args[0] push(path, user, comment, type) end end c.desc "Rebase '#{GitflowType.base_branch(type)}' to current #{GitflowType.name(type)}" c.command :rebase do |rebase| rebase.action do |, , args| path = File.([:path]) user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/rebase") help_now!('user name is required') if user and user.empty? rebase(path, user, type) end end c.desc "Finish current #{GitflowType.name(type)}" c.command :finish do |finish| finish.action do |, , args| path = File.([:path]) user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/finish") help_now!('user name is required') if user and user.empty? finish(path, user, type) end end c.desc "Publish current #{GitflowType.name(type)}" c.command :publish do |publish| publish.action do |, , args| path = File.([:path]) user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/publish") help_now!('user name is required') if user and user.empty? publish(path, user, type) end end c.desc "Delete #{GitflowType.name(type)} with name" c.command :delete do |delete| delete.action do |, , args| path = File.([:path]) user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/delete") help_now!('user name is required') if user and user.empty? help_now!("#{GitflowType.name(type)} name is required") if args.length < 1 name = args[0] delete(path, user, name, type) end end c.desc "List all the #{GitflowType.name(type)}s" c.command :list do |list| list.flag %i[v version] , default_value: 'all versions' list.desc "Print list of TREE format." list.command :tree do |tree| tree.action do |, , args| LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/list/tree") Logger.highlight("Generating #{GitflowType.name(type)} tree of all version...") if args.length < 1 path = File.([:path]) user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase list(path, user, type, ) end end list.desc "Print list of JSON format." list.command :json do |json| json.action do |, , args| LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/list/json") [:json] = true path = File.([:path]) user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase list(path, user, type, ) end end end end end |
.finish(path, user, type) ⇒ Object
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 |
# File 'lib/big_keeper/command/feature&hotfix/finish.rb', line 17 def self.finish(path, user, type) begin # Parse Bigkeeper file BigkeeperParser.parse("#{path}/Bigkeeper") home_branch_name = GitOperator.new.current_branch(path) branch_name = ModuleCacheOperator.new(path).branch_name Logger.error("Not a #{GitflowType.name(type)} branch, exit.") unless branch_name.include? GitflowType.name(type) # Cache git modules if ModuleCacheOperator.new(path).all_path_modules.empty? Logger.error("Branch '#{branch_name}' is already finished, exit.") end ModuleCacheOperator.new(path).cache_git_modules(ModuleCacheOperator.new(path).all_path_modules) modules = ModuleCacheOperator.new(path).current_path_modules_path(path) #modules = ModuleCacheOperator.new(path).remain_git_modules # Rebase modules and modify module as git modules.each do |module_name| ModuleService.new.finish(path, user, module_name, branch_name, type) end Logger.highlight("Finish branch '#{branch_name}' for 'Home'") # Delete all path modules # ModuleCacheOperator.new(path).cache_path_modules([], [], []) # Install DepService.dep_operator(path, user).install(false) # Open home workspace DepService.dep_operator(path, user).open # Push home changes to remote GitService.new.verify_push(path, "finish branch #{home_branch_name}", home_branch_name, 'Home') ensure end end |
.generate_list_with_option(options, file_path, version, home_branches) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/big_keeper/command/feature&hotfix/list.rb', line 56 def self.generate_list_with_option(, file_path, version, home_branches) if [:json] ListGenerator.generate_json(file_path, home_branches, version) else ListGenerator.generate_tree(file_path, home_branches, version) end end |
.get_module_info(path, user, type, version, home_branches, is_print_log) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/big_keeper/command/feature&hotfix/list.rb', line 36 def self.get_module_info(path, user, type, version, home_branches, is_print_log) #get module list modules = BigkeeperParser.module_names git_operator = GitOperator.new module_info_list = [] modules.each do |module_name| module_full_path = BigkeeperParser.module_full_path(path, user, module_name) #local project verify if !File.exist? module_full_path Logger.default("No local repository for module '#{module_name}', clone it...") if is_print_log module_git = BigkeeperParser.module_git(module_name) git_operator.clone(File.("#{module_full_path}/../"), module_git) end #每个模块详细信息 module_branch_info = ModuleService.new.module_info(module_full_path, home_branches, user, type, module_name, version) module_info_list << module_branch_info end module_info_list end |
.home(name, params) ⇒ Object
15 16 17 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 15 def self.home(name, params) BigkeeperParser.parse_home(name, params) end |
.image_command ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/big_keeper/command/image.rb', line 5 def self.image_command desc 'Image operations' command :image do | c | c.desc "Detect duplicate name images." c.command :name do | name | name.action do | , , args | LeanCloudLogger.instance.set_command("image/name") path = File.([:path]) BigResources::ImageAnalyzeUtil.get_duplicate_name_file_with_type(path, BigResources::PNG) end end c.desc "Detect duplicate content images." c.command :content do | content | content.action do | , , args | LeanCloudLogger.instance.set_command("image/content") path = File.([:path]) BigResources::ImageAnalyzeUtil.get_duplicate_content_file_with_type(path, BigResources::PNG) end end end end |
.list(path, user, type, options) ⇒ Object
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 |
# File 'lib/big_keeper/command/feature&hotfix/list.rb', line 8 def self.list(path, user, type, ) BigkeeperParser.parse("#{path}/Bigkeeper") home_path = File.(path) #get home project branches branches = GitService.new.branchs_with_type(home_path, type) #get modules list is_print_log = false if [:json] #get search version version = [:version] cache_path = File.("#{path}/.bigkeeper") json_path = "#{cache_path}/branches.json" begin #get cache file path FileUtils.mkdir_p(cache_path) unless File.exist?(cache_path) file = File.new(json_path, 'w') begin #get all modules info module_list_dic = get_module_info(path, user, type, version, branches, is_print_log) file << module_list_dic.to_json file.close end #print list generate_list_with_option(, json_path, version, branches) ensure file.close end end |
.mod(name, params) ⇒ Object
19 20 21 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 19 def self.mod(name, params) BigkeeperParser.parse_mod(name, params) end |
.modules ⇒ Object
23 24 25 26 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 23 def self.modules BigkeeperParser.parse_modules yield if block_given? end |
.param(key, value) ⇒ Object
38 39 40 41 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 38 def self.param(key, value) BigkeeperParser.parse_param(key, value) yield if block_given? end |
.pod_command ⇒ Object
6 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 |
# File 'lib/big_keeper/command/pod.rb', line 6 def self.pod_command desc 'Podfile operation' command :podfile do |podfile| podfile.desc 'Podfile' podfile.desc 'Detect podname should be locked.' podfile.command :detect do |detect| detect.action do |, , args| LeanCloudLogger.instance.set_command("podfile/detect") path = File.([:path]) podfile_detect(path) end end podfile.desc 'Lock podname should be locked.' podfile.command :lock do |lock| lock.action do |, , args| LeanCloudLogger.instance.set_command("podfile/lock") path = File.([:path]) podfile_lock(path) end end podfile.desc 'Update modules should be upgrade.' podfile.command :update do |update| update.action do |, , args| LeanCloudLogger.instance.set_command("podfile/update") path = File.([:path]) podfile_modules_update(path) end end end end |
.podfile_detect(path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/big_keeper/command/pod/podfile.rb', line 11 def self.podfile_detect(path) # Parse Bigkeeper file BigkeeperParser.parse("#{path}/Bigkeeper") # Get modules' name module_list = BigkeeperParser.module_names # initialize PodfileDetector detector = PodfileDetector.new(path, module_list) # Get unlocked third party pods list unlock_pod_list = detector.get_unlock_pod_list # Print out unlock pod list unlock_pod_list.each do |pod_name| Logger.default("#{pod_name} should be locked.") end Logger.separator end |
.podfile_lock(path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/big_keeper/command/pod/podfile.rb', line 28 def self.podfile_lock(path) # Parse Bigkeeper file BigkeeperParser.parse("#{path}/Bigkeeper") # Get modules' name module_list = BigkeeperParser.module_names # initialize PodfileDetector detector = PodfileDetector.new(path, module_list) # Get unlocked third party pods list unlock_pod_list = detector.get_unlock_pod_list # Get Version dictionary = detector.deal_lock_file(path, unlock_pod_list) if dictionary.empty? Logger.warning("There is nothing to be locked.") else PodfileOperator.new.find_and_lock("#{path}/Podfile", dictionary) Logger.highlight("The Podfile has been changed.") Logger.separator end end |
.podfile_modules_update(path) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/big_keeper/command/pod/podfile.rb', line 51 def self.podfile_modules_update(path) # Parse Bigkeeper file BigkeeperParser.parse("#{path}/Bigkeeper") # Get modules' name module_list = BigkeeperParser.module_names # initialize PodfileDetector detector = PodfileModuleDetector.new(path) # Get module latest version module_dictionary = detector.check_version_list # Check if anything should be upgrade if module_dictionary.empty? Logger.warning("There is nothing to be upgrade.") else PodfileOperator.new.find_and_upgrade("#{path}/Podfile", module_dictionary) Logger.highlight("The Podfile has been changed.") end end |
.publish(path, user, type) ⇒ Object
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 |
# File 'lib/big_keeper/command/feature&hotfix/publish.rb', line 17 def self.publish(path, user, type) begin # Parse Bigkeeper file 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) path_modules = ModuleCacheOperator.new(path).current_path_modules Logger.error("You have unfinished modules #{path_modules}, Use 'finish' first please.") unless path_modules.empty? # Push modules changes to remote then rebase modules = ModuleCacheOperator.new(path).current_git_modules modules.each do |module_name| ModuleService.new.pre_publish(path, user, module_name, branch_name, type) end # Install DepService.dep_operator(path, user).install(false) # Modify module as git modules.each do |module_name| ModuleService.new.publish(path, user, module_name, branch_name, type) end Logger.highlight("Publish branch '#{branch_name}' for 'Home'") # Recover home DepService.dep_operator(path, user).recover # Push home changes to remote GitService.new.verify_push(path, "publish branch #{branch_name}", branch_name, 'Home') # Rebase Home GitService.new.verify_rebase(path, GitflowType.base_branch(type), 'Home') `open #{BigkeeperParser.home_pulls()}` ensure end end |
.pull(path, user, type) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/big_keeper/command/feature&hotfix/pull.rb', line 7 def self.pull(path, user, type) begin # Parse Bigkeeper file 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 = ModuleCacheOperator.new(path).current_path_modules 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/big_keeper/command/feature&hotfix/push.rb', line 8 def self.push(path, user, comment, type) begin # Parse Bigkeeper file 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 = ModuleCacheOperator.new(path).current_path_modules modules.each do |module_name| ModuleService.new.push(path, user, module_name, branch_name, type, comment) end Logger.highlight("Push branch '#{branch_name}' for 'Home'...") GitService.new.verify_push(path, comment, branch_name, 'Home') ensure end end |
.rebase(path, user, 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 |
# File 'lib/big_keeper/command/feature&hotfix/rebase.rb', line 7 def self.rebase(path, user, type) begin # Parse Bigkeeper file 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 = ModuleCacheOperator.new(path).current_path_modules modules.each do |module_name| ModuleService.new.rebase(path, user, module_name, branch_name, type) end Logger.highlight("Rebase '#{GitflowType.base_branch(type)}' "\ "to branch '#{branch_name}' for 'Home'...") # Rebase Home Logger.error("You have some changes in branch '#{branch_name}' "\ "for 'Home'. Use 'push' first please") if GitOperator.new.has_changes(path) GitService.new.verify_rebase(path, GitflowType.base_branch(type), 'Home') ensure end end |
.release_command ⇒ Object
6 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/big_keeper/command/release.rb', line 6 def self.release_command desc 'Gitflow release operations' command :release do |c| c.desc 'Release home project operations' c.command :home do |home| home.desc 'Start release home project' home.command :start do |start| start.action do |, , args| path = File.([:path]) version = [:ver] user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("release/home/start") help_now!('user name is required') if user and user.empty? raise Logger.error("release version is required") if version == nil release_home_start(path, version, user) end end home.desc 'Finish release home project' home.command :finish do |finish| finish.action do |, , args| path = File.([:path]) version = [:ver] LeanCloudLogger.instance.set_command("release/home/finish") raise Logger.error("release version is required") if version == nil release_home_finish(path, version) end end end c.desc 'release module' c.switch [:i,:ignore] c.command :module do |m| m.desc 'Start release module project' m.command :start do |start| start.action do |, , args| path = File.([:path]) version = [:ver] user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("release/module/start") help_now!('module name is required') if args.length != 1 raise Logger.error("release version is required") if version == nil module_name = args[0] release_module_start(path, version, user, module_name, [:ignore]) end end m.desc 'finish release module project' m.switch [:s,:spec] m.command :finish do |finish| finish.action do |, , args| path = File.([:path]) version = [:ver] user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase LeanCloudLogger.instance.set_command("release/module/finish") help_now!('module name is required') if args.length != 1 raise Logger.error("release version is required") if version == nil module_name = args[0] release_module_finish(path, version, user, module_name, [:spec]) end end end end end |
.release_home_finish(path, version) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/big_keeper/command/release/home.rb', line 53 def self.release_home_finish(path, version) BigkeeperParser.parse("#{path}/Bigkeeper") version = BigkeeperParser.version if version == 'Version in Bigkeeper file' Logger.highlight("Start finish release home for #{version}") if GitOperator.new.has_branch(path, "release/#{version}") if GitOperator.new.current_branch(path) != "release/#{version}" GitOperator.new.checkout(path, "release/#{version}") end GitService.new.verify_push(path, "finish release branch", "release/#{version}", 'Home') # master GitOperator.new.checkout(path, "master") GitOperator.new.merge(path, "release/#{version}") GitService.new.verify_push(path, "release V#{version}", "master", 'Home') GitOperator.new.tag(path, version) # release branch GitOperator.new.checkout(path, "release/#{version}") CacheOperator.new(path).load('Podfile') CacheOperator.new(path).clean() GitOperator.new.commit(path, "reset #{version} Podfile") GitService.new.verify_push(path, "reset #{version} Podfile", "release/#{version}", 'Home') # develop GitOperator.new.checkout(path, "develop") GitOperator.new.merge(path, "release/#{version}") GitService.new.verify_push(path, "merge release/#{version} to develop", "develop", 'Home') GitOperator.new.check_diff(path, "develop", "master") Logger.highlight("Finish release home for #{version}") else raise Logger.error("There is no release/#{version} branch, please use release home start first.") end end |
.release_home_start(path, version, user) ⇒ Object
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 46 47 48 49 50 51 |
# File 'lib/big_keeper/command/release/home.rb', line 10 def self.release_home_start(path, version, user) BigkeeperParser.parse("#{path}/Bigkeeper") version = BigkeeperParser.version if version == 'Version in Bigkeeper file' modules = BigkeeperParser.module_names #stash StashService.new.stash_all(path, GitOperator.new.current_branch(path), user, modules) # delete cache CacheOperator.new(path).clean() # cache Podfile CacheOperator.new(path).save('Podfile') # check GitOperator.new.check_diff(path, "develop", "master") #checkout release branch Logger.highlight(%Q(Start to checkout Branch release/#{version})) if GitOperator.new.current_branch(path) != "release/#{version}" if GitOperator.new.has_branch(path, "release/#{version}") GitOperator.new.checkout(path, "release/#{version}") else GitflowOperator.new.start(path, version, GitflowType::RELEASE) GitOperator.new.push_to_remote(path, "release/#{version}") end end Logger.highlight(%Q(Start to release/#{version})) # step 2 replace_modules PodfileOperator.new.replace_all_module_release(path, user, modules, ModuleOperateType::RELEASE) # step 3 change Info.plist value InfoPlistOperator.new.change_version_build(path, version) GitService.new.verify_push(path, "Change version to #{version}", "release/#{version}", 'Home') DepService.dep_operator(path, user).install(true) XcodeOperator.open_workspace(path) end |
.release_module_finish(path, version, user, module_name, spec) ⇒ Object
release finish
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 33 def self.release_module_finish(path, version, user, module_name, spec) BigkeeperParser.parse("#{path}/Bigkeeper") module_path = BigkeeperParser.module_full_path(path, user, module_name) # check commit Logger.error("current branch has unpush files") if GitOperator.new.has_changes(module_path) #修改 podspec 文件 # TO DO: - advanced to use Regular Expression has_change = PodfileOperator.new.podspec_change(%Q(#{module_path}/#{module_name}.podspec), version, module_name) GitService.new.verify_push(module_path, "Change version number", "develop", "#{module_name}") if has_change == true # check out master Logger.highlight("'#{module_name}' checkout branch to master...") GitService.new.verify_checkout_pull(module_path, "master") Logger.highlight(%Q(Merge develop to master)) # merge develop to master GitOperator.new.merge(module_path, "develop") GitOperator.new.push_to_remote(module_path, "master") GitOperator.new.tag(module_path, version) # pod repo push if spec == true PodOperator.pod_repo_push(module_path, module_name, BigkeeperParser.source_spec_path(module_name), version) end end |
.release_module_start(path, version, user, module_name, ignore) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/big_keeper/command/release/module.rb', line 11 def self.release_module_start(path, version, user, module_name, ignore) BigkeeperParser.parse("#{path}/Bigkeeper") module_path = BigkeeperParser.module_full_path(path, user, module_name) # stash StashService.new.stash(module_path, GitOperator.new.current_branch(module_path), module_name) #check if ignore != true GitOperator.new.check_merge(module_path, "feature/#{version}") GitOperator.new.check_diff(module_path, "develop", "master") Logger.highlight(%Q(#{module_name} release check finish)) end # checkout to develop branch Logger.highlight(%Q(Start checkout #{module_name} to Branch develop)) GitService.new.verify_checkout_pull(module_path, "develop") Logger.highlight(%Q(#{module_name} release start finish)) end |
.source(name) ⇒ Object
28 29 30 31 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 28 def self.source(name) BigkeeperParser.parse_source(name) yield if block_given? end |
.spec_add ⇒ Object
6 7 8 |
# File 'lib/big_keeper/command/spec/add.rb', line 6 def self.spec_add Logger.default('Coming soon.') end |
.spec_analyze(path, is_all, find_module_names) ⇒ 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/big_keeper/command/spec/analyze.rb', line 7 def self.spec_analyze(path,is_all,find_module_names) # Parse Bigkeeper file BigkeeperParser.parse("#{path}/Bigkeeper") is_default = !is_all&&find_module_names.size==0 if is_all && find_module_names.size>0 Logger.error("parameter conflict: [--all] | [module_names]") return end Logger.highlight('Start spec analyze...') Logger.default(Time.now.to_s) # Parse Bigkeeper file # BigkeeperParser.parse("#{path}/Bigkeeper") # module_names = BigkeeperParser.module_names # find modules Logger.highlight('Get all modules...') module_names = [] pod_path = path+"/Pods/" dir = Dir.open(pod_path) dir.each do |dir_name| if !dir_name.include?(".") && dir_name != "Headers" && dir_name != "Local Podspecs" && dir_name != "Target Support Files" module_names[module_names.size]=dir_name end end for input_moudle_name in find_module_names do if !module_names.include?(input_moudle_name) Logger.error("["+input_moudle_name+"] not exist.") end end # setup modules module_list = [] module_keyword_map = Hash.new file_count = 0 for module_name in module_names do library = LibraryModel.new(module_name) library.get_all_public_file(path) module_list[module_list.size]=library module_keyword_map[module_name]=library.keyword_list if is_all || find_module_names.include?(library.name) file_count = file_count + library.file_list.size end end # analyze modules spec Logger.highlight('Analyze modules...') Logger.default(Time.now.to_s) file_index = 0 for library in module_list do if is_all || find_module_names.include?(library.name) Logger.default('Analyzing ' + library.name) file_index = file_index + library.file_list.size library.spec_dependece_library(module_keyword_map.clone)#(Hash.new(module_keyword_map)).to_hash) progress = (file_index*100.0)/file_count progress = format("%.02f", progress).to_f Logger.default('progress >>>> ' + String(progress) + '% [' + library.name + ' done] ') end end Logger.highlight('Analyze complete.') Logger.default(Time.now.to_s) # log spec info for library in module_list do if is_all || find_module_names.include?(library.name) Logger.highlight("\n-"+library.name+":") for spec_library in library.spec_library do puts " -"+spec_library end end end # save cache to file if is_all end end |
.spec_command ⇒ Object
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/big_keeper/command/spec.rb', line 11 def self.spec_command desc 'Spec operations' command :spec do |spec| spec.switch [:a,:all] spec.desc 'Analyze spec dependency infomation.' spec.command :analyze do |analyze| analyze.action do |, , args| LeanCloudLogger.instance.set_command("spec/analyze") path = File.([:path]) is_all = [:all] module_names = args spec_analyze(path, is_all, module_names) end end spec.desc 'List all the specs.' spec.command :list do | list | list.action do |, , args| LeanCloudLogger.instance.set_command("spec/list") path = File.([:path]) version = [:ver] user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase spec_list(path, user, ) end end spec.desc 'Sync Module dependency from Home.' spec.command :sync do | sync| sync.action do |, , args| LeanCloudLogger.instance.set_command("spec/sync") path = File.([:path]) version = [:ver] user = [:user].gsub(/[^0-9A-Za-z]/, '').downcase module_name = args spec_sync(path, version, user, module_name) end end spec.desc 'Add a spec (Coming soon).' spec.command :add do |add| add.action do spec_add() end end spec.desc 'Delete a spec (Coming soon).' spec.command :delete do |delete| delete.action do spec_delete() end end spec.desc 'Search a spec with name (Coming soon).' spec.command :search do |search| search.action do spec_search() end end end end |
.spec_delete ⇒ Object
6 7 8 |
# File 'lib/big_keeper/command/spec/delete.rb', line 6 def self.spec_delete Logger.default('Coming soon.') end |
.spec_list(path, user, options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/big_keeper/command/spec/list.rb', line 5 def self.spec_list(path, user, ) BigkeeperParser.parse("#{path}/Bigkeeper") module_dic = BigkeeperParser.parse_modules module_list = Array.new module_dic.keys.each do | key | dic = Hash["module_name" => key, "git" => module_dic[key][:git], "pulls" => module_dic[key][:pulls]] module_list << dic end json = JSON.pretty_generate(module_list) puts json end |
.spec_search ⇒ Object
6 7 8 |
# File 'lib/big_keeper/command/spec/search.rb', line 6 def self.spec_search Logger.default('Coming soon.') end |
.spec_sync(path, version, user, module_name) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/big_keeper/command/spec/sync.rb', line 6 def self.spec_sync(path, version, user, module_name) # Parse Bigkeeper file BigkeeperParser.parse("#{path}/Bigkeeper") Logger.default('Coming soon.') end |
.start(path, version, user, modules, type) ⇒ 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/big_keeper/command/feature&hotfix/start.rb', line 20 def self.start(path, version, user, modules, type) begin # Parse Bigkeeper file p "----------1.开始解析#{path}/Bigkeeper" BigkeeperParser.parse("#{path}/Bigkeeper") version = BigkeeperParser.version if version == 'Version in Bigkeeper file' p "----------2.version:#{version}" full_name = "#{version}" #full_name = "#{version}_#{user}_#{name}" p "----------3.full_name:#{full_name}" branch_name = "#{GitflowType.name(type)}/#{full_name}" p "----------4.branch_name:#{branch_name}" ModuleCacheOperator.new(path).cache_branch_name(branch_name) home_branch_name = "release/#{version}" p "----------5.home_branch_name:#{home_branch_name}" p "----------6.path:#{path}" p "----------7.1验证home_branch" GitService.new.verify_home_branch(path, home_branch_name, OperateType::START) #GitService.new.verify_home_branch(path, branch_name, OperateType::START) stash_modules = ModuleCacheOperator.new(path).all_path_modules p "----------8.stash_modules:#{stash_modules}" # Stash current branch # p "----------9.stash_all:path:#{path} branch_name:#{branch_name} user:#{user} #{path} stash_modules:#{stash_modules}" StashService.new.stash_all(path, branch_name, user, stash_modules,version) # Verify input modules p "----------10.验证modules是否包含在Bigkeeper文件中" modules = BigkeeperParser.verify_modules(modules) p "----------11.home 添加 release/#{version} 分支" Logger.highlight("Add branch release/#{version} for 'Home'...") # Start home feature # GitService.new.start(path, full_name, type) GitService.new.startHome(path, version, GitflowType::RELEASE) # Clean module cache # p "----------11.清空modules缓存" ModuleCacheOperator.new(path).clean_modules # Cache all path modules p "----------12.Cache all path modules" ModuleCacheOperator.new(path).cache_path_modules(modules, modules, []) modules = ModuleCacheOperator.new(path).remain_path_modules p "----------13.Backup home" # Backup home DepService.dep_operator(path, user).backup p "----------14.为模块建立分支并将podfile中地址切换到本地" # Start modules feature and modify module as path modules.each do |module_name| ModuleService.new.add(path, user, module_name, full_name, type) end p "----------15.pod update" # install DepService.dep_operator(path, user).install(false ) p "----------16.打开 workspace" # Open home workspace DepService.dep_operator(path, user).open p "----------17.Push home changes to remote" # Push home changes to remote Logger.highlight("Push branch release/#{version} for 'Home'...") GitService.new.verify_push( path, "start branch #{home_branch_name}", home_branch_name, 'Home') ensure end end |
.switch_to(path, version, user, full_name, type) ⇒ Object
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 46 47 |
# File 'lib/big_keeper/command/feature&hotfix/switch.rb', line 10 def self.switch_to(path, version, user, full_name, type) begin # Parse Bigkeeper file p "1.switch_to #{version} 解析Bigkeeper" BigkeeperParser.parse("#{path}/Bigkeeper") version = BigkeeperParser.version if version == 'Version in Bigkeeper file' branch_name = "#{GitflowType.name(type)}/#{full_name}" ModuleCacheOperator.new(path).cache_branch_name(branch_name) home_branch_name = "release/#{full_name}" GitService.new.verify_home_branch(path, home_branch_name, OperateType::SWITCH) stash_modules = ModuleCacheOperator.new(path).all_path_modules p "2.switch_to 暂存所有" # Stash current branch StashService.new.stash_all(path, branch_name, user, stash_modules,full_name) p "3.switch_to checkout #{home_branch_name}" # Switch to new feature GitOperator.new.checkout(path, home_branch_name) GitOperator.new.pull(path) p "4.switch_to" # Apply home stash StashService.new.pop_stash(path, home_branch_name, 'Home') #modules = ModuleCacheOperator.new(path).all_path_modules modules = ModuleCacheOperator.new(path).current_path_modules_path(path) modules.each do |module_name| ModuleService.new.switch_to(path, user, module_name, branch_name, type) end p "5.switch_to" # Install DepService.dep_operator(path, user).install(false) p "6.switch_to" # Open home workspace DepService.dep_operator(path, user).open ensure end end |
.update(path, user, modules, type) ⇒ 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/big_keeper/command/feature&hotfix/update.rb', line 20 def self.update(path, user, modules, type) begin # Parse Bigkeeper file BigkeeperParser.parse("#{path}/Bigkeeper") home_branch_name = GitOperator.new.current_branch(path) branch_name = ModuleCacheOperator.new(path).branch_name # Logger.error("Not a #{GitflowType.name(type)} branch, exit.") unless branch_name.include? GitflowType.name(type) # Logger.error("Not a #{GitflowType.name(GitflowType::RELEASE)} branch, exit.") unless branch_name.include? GitflowType.name(GitflowType::RELEASE) full_name = branch_name.gsub(/#{GitflowType.name(type)}\//, '') current_modules = ModuleCacheOperator.new(path).current_path_modules_path(path) # Verify input modules modules = BigkeeperParser.verify_modules(modules) Logger.highlight("Start to update modules for branch '#{branch_name}'...") add_modules = modules - current_modules del_modules = current_modules - modules # Clean module cache ModuleCacheOperator.new(path).clean_modules ModuleCacheOperator.new(path).cache_path_modules(modules, add_modules, del_modules) remain_path_modules = ModuleCacheOperator.new(path).remain_path_modules if add_modules.empty? and del_modules.empty? Logger.default("There is nothing changed with modules #{modules}.") else type = # Modify podfile as path and Start modules feature remain_path_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 end # Install DepService.dep_operator(path, user).install(false) # Open home workspace DepService.dep_operator(path, user).open # Push home changes to remote GitService.new.verify_push(path, "update branch #{home_branch_name}", home_branch_name, 'Home') ensure end end |
.user(name) ⇒ Object
10 11 12 13 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 10 def self.user(name) BigkeeperParser.parse_user(name) yield if block_given? end |
.version(name) ⇒ Object
6 7 8 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 6 def self.version(name) BigkeeperParser.parse_version(name) end |