diff --git a/Gemfile b/Gemfile index f795e05..39672db 100644 --- a/Gemfile +++ b/Gemfile @@ -8,8 +8,3 @@ gemspec group :test do gem 'rake' end - -if RUBY_VERSION =~ /1.9/ - Encoding.default_external = Encoding::UTF_8 - Encoding.default_internal = Encoding::UTF_8 -end diff --git a/Gemfile.lock b/Gemfile.lock index 2ed79d4..47c5ca1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bigkeeper (0.9.9) + bigkeeper (0.9.11) big_resources big_stash (~> 0.1) cocoapods @@ -18,7 +18,7 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - ast (2.3.0) + ast (2.4.0) atomos (0.1.3) big_resources (0.1.2) chunky_png @@ -30,26 +30,26 @@ GEM gli (~> 2.16) chunky_png (1.3.11) claide (1.0.2) - cocoapods (1.6.1) + cocoapods (1.5.0) activesupport (>= 4.0.2, < 5) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.6.1) + cocoapods-core (= 1.5.0) cocoapods-deintegrate (>= 1.0.2, < 2.0) - cocoapods-downloader (>= 1.2.2, < 2.0) + cocoapods-downloader (>= 1.2.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-stats (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.3.1, < 2.0) + cocoapods-trunk (>= 1.3.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) - fourflusher (>= 2.2.0, < 3.0) + fourflusher (~> 2.0.1) gh_inspector (~> 1.0) - molinillo (~> 0.6.6) + molinillo (~> 0.6.5) nap (~> 1.0) - ruby-macho (~> 1.4) - xcodeproj (>= 1.8.1, < 2.0) - cocoapods-core (1.6.1) + ruby-macho (~> 1.1) + xcodeproj (>= 1.5.7, < 2.0) + cocoapods-core (1.5.0) activesupport (>= 4.0.2, < 6) fuzzy_match (~> 2.0.4) nap (~> 1.0) @@ -67,7 +67,7 @@ GEM colorize (0.8.1) concurrent-ruby (1.1.5) escape (0.0.4) - fourflusher (2.2.0) + fourflusher (2.0.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) gli (2.18.0) @@ -78,11 +78,11 @@ GEM nanaimo (0.2.6) nap (1.1.0) netrc (0.11.0) - parallel (1.12.0) - parser (2.4.0.0) - ast (~> 2.2) + parallel (1.12.1) + parser (2.5.1.2) + ast (~> 2.4.0) plist (3.5.0) - powerpack (0.1.1) + powerpack (0.1.2) rainbow (2.2.2) rake rake (10.5.0) @@ -98,7 +98,7 @@ GEM thread_safe (0.3.6) tzinfo (1.2.5) thread_safe (~> 0.1) - unicode-display_width (1.3.0) + unicode-display_width (1.4.0) xcodeproj (1.8.2) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) diff --git a/bin/big b/bin/big index 2efc2d4..3a37137 100755 --- a/bin/big +++ b/bin/big @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require "bundler/setup" +#require "bundler/setup" require "big_keeper" # You can add fixtures and/or initialization code here to make experimenting diff --git a/lib/big_keeper.rb b/lib/big_keeper.rb index 9182947..2e1bfe3 100644 --- a/lib/big_keeper.rb +++ b/lib/big_keeper.rb @@ -14,6 +14,7 @@ require 'big_keeper/command/spec' require 'big_keeper/command/image' require 'big_keeper/command/init' +require 'big_keeper/command/client' require 'big_keeper/service/git_service' require 'big_keeper/util/leancloud_logger' @@ -40,17 +41,17 @@ module BigKeeper exit end - pre do |global_options, command, options, args| - LeanCloudLogger.instance.start_log(global_options, args) - end - - post do |global_options, command, options, args| - is_show_log = true - if global_options[:log] == 'false' - is_show_log = false - end - LeanCloudLogger.instance.end_log(true, is_show_log) - end + # pre do |global_options, command, options, args| + # LeanCloudLogger.instance.start_log(global_options, args) + # end + # + # post do |global_options, command, options, args| + # is_show_log = true + # if global_options[:log] == 'true' + # is_show_log = false + # end + # LeanCloudLogger.instance.end_log(true, is_show_log) + # end feature_and_hotfix_command(GitflowType::FEATURE) @@ -66,6 +67,8 @@ module BigKeeper init_command + client_command + desc 'Show version of bigkeeper' command :version do |version| version.action do |global_options, options, args| diff --git a/lib/big_keeper/command/client.rb b/lib/big_keeper/command/client.rb new file mode 100644 index 0000000..f0141da --- /dev/null +++ b/lib/big_keeper/command/client.rb @@ -0,0 +1,50 @@ +require 'big_keeper/util/leancloud_logger' +require 'big_keeper/command/pod/podfile' +require 'big_keeper/command/spec/list' +require 'big_keeper/util/list_generator' + +module BigKeeper + + def self.client_command + desc 'API for bigkeeper-client.' + command :client do | c | + c.desc 'Commands about operate modules.' + c.command :modules do |modules| + modules.desc 'Get modules list from Bigkeeper file.' + modules.command :list do |list| + list.action do |global_options, options, args| + LeanCloudLogger.instance.set_command("spec/list") + path = File.expand_path(global_options[:path]) + version = global_options[:ver] + user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase + spec_list(path, user, options) + end + end + modules.desc 'Update modules.' + modules.command :update do |update| + update.action do |global_options, options, args| + LeanCloudLogger.instance.set_command("spec/list") + path = File.expand_path(global_options[:path]) + version = global_options[:ver] + user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase + spec_list(path, user, options) + end + end + end + c.desc 'Commands about features.' + c.command :feature do |feature| + feature.desc "List all the features including origin." + feature.command :list do | list | + list.flag %i[v version] , default_value: 'all versions' + list.action do |global_options, options, args| + LeanCloudLogger.instance.set_command("feature/list/json") + options[:json] = true + path = File.expand_path(global_options[:path]) + user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase + list(path, user, GitflowType::FEATURE, options) + end + end + end + end + end +end diff --git a/lib/big_keeper/command/feature&hotfix/delete.rb b/lib/big_keeper/command/feature&hotfix/delete.rb index 010a212..212c60c 100644 --- a/lib/big_keeper/command/feature&hotfix/delete.rb +++ b/lib/big_keeper/command/feature&hotfix/delete.rb @@ -20,9 +20,9 @@ def self.delete(path, user, name, type) # Parse Bigkeeper file BigkeeperParser.parse("#{path}/Bigkeeper") branch_name = "#{GitflowType.name(type)}/#{name}" + version = 'all version' modules = BigkeeperParser.module_names - modules.each do |module_name| module_full_path = BigkeeperParser.module_full_path(path, user, module_name) diff --git a/lib/big_keeper/command/feature&hotfix/list.rb b/lib/big_keeper/command/feature&hotfix/list.rb index 9c114b2..4113daa 100644 --- a/lib/big_keeper/command/feature&hotfix/list.rb +++ b/lib/big_keeper/command/feature&hotfix/list.rb @@ -19,7 +19,7 @@ def self.list(path, user, type, options) begin #get cache file path FileUtils.mkdir_p(cache_path) unless File.exist?(cache_path) - file = File.new(json_path, 'w') + file = File.new(json_path, 'w', :encoding => 'UTF-8') begin #get all modules info module_list_dic = get_module_info(path, user, type, version, branches, is_print_log) diff --git a/lib/big_keeper/dependency/dep_pod_operator.rb b/lib/big_keeper/dependency/dep_pod_operator.rb index be4b963..08218d2 100644 --- a/lib/big_keeper/dependency/dep_pod_operator.rb +++ b/lib/big_keeper/dependency/dep_pod_operator.rb @@ -20,10 +20,10 @@ def recover def update_module_config(module_name, module_operate_type) file = "#{@path}/Podfile" - temp_file = Tempfile.new('.Podfile.tmp') + temp_file = Tempfile.new('.Podfile.tmp', :encoding => 'UTF-8') begin - File.open(file, 'r') do |file| + File.open(file, 'r', :encoding => 'UTF-8') do |file| file.each_line do |line| temp_file.puts generate_module_config(line, module_name, module_operate_type) end @@ -84,7 +84,7 @@ def generate_module_config(line, module_name, module_operate_type) def origin_config_of_module(module_name) origin_config = '' - File.open("#{@path}/.bigkeeper/Podfile", 'r') do |file| + File.open("#{@path}/.bigkeeper/Podfile", 'r', :encoding => 'UTF-8') do |file| file.each_line do |line| if line =~ /(\s*)pod(\s*)('|")#{module_name}('|")([\s\S]*)/ origin_config = line diff --git a/lib/big_keeper/service/git_service.rb b/lib/big_keeper/service/git_service.rb index 9535b05..56a6774 100644 --- a/lib/big_keeper/service/git_service.rb +++ b/lib/big_keeper/service/git_service.rb @@ -114,8 +114,9 @@ def current_branch_type(path) def branchs_with_type(path, type) branchs = [] Dir.chdir(path) do - IO.popen('git branch -r') do | io | + IO.popen('git branch -a') do | io | io.each do | line | + branchs << line.gsub('\n', '') if line.include?('develop') branchs << line.gsub(/\s/, '') if line =~ /[\s\S]*#{GitflowType.name(type)}*/ end end diff --git a/lib/big_keeper/util/cache_operator.rb b/lib/big_keeper/util/cache_operator.rb index 9e9189d..559864a 100644 --- a/lib/big_keeper/util/cache_operator.rb +++ b/lib/big_keeper/util/cache_operator.rb @@ -32,7 +32,7 @@ def initialize(path) FileUtils.mkdir_p(@cache_path) unless File.exist?(@cache_path) if File.exist?("#{@cache_path}/module.cache") - file = File.open("#{@cache_path}/module.cache", 'r') + file = File.open("#{@cache_path}/module.cache", 'r', :encoding => 'UTF-8') @modules = JSON.load(file.read(), :encoding => 'UTF-8') file.close else @@ -110,7 +110,7 @@ def clean_modules end def cache_modules - file = File.new("#{@cache_path}/module.cache", 'w') + file = File.new("#{@cache_path}/module.cache", 'w', :encoding => 'UTF-8') file << @modules.to_json file.close end diff --git a/lib/big_keeper/util/file_operator.rb b/lib/big_keeper/util/file_operator.rb index a8fc8ba..20c8112 100644 --- a/lib/big_keeper/util/file_operator.rb +++ b/lib/big_keeper/util/file_operator.rb @@ -29,5 +29,5 @@ def find_all_code_file(path) return header_file_list+m_file_list end end - + end diff --git a/lib/big_keeper/util/gradle_file_operator.rb b/lib/big_keeper/util/gradle_file_operator.rb index b829c78..7842b3e 100644 --- a/lib/big_keeper/util/gradle_file_operator.rb +++ b/lib/big_keeper/util/gradle_file_operator.rb @@ -46,7 +46,7 @@ def update_module_settings(module_name, settings_file, depend_modules) dest_path = File.dirname(big_settings_file) FileUtils.mkdir_p(dest_path) unless File.exist?(dest_path) - file = File.new(big_settings_file, 'w') + file = File.new(big_settings_file, 'w', :encoding => 'UTF-8') begin file << result file.close @@ -58,9 +58,9 @@ def update_module_settings(module_name, settings_file, depend_modules) return end - temp_file = Tempfile.new('.settings.gradle.tmp') + temp_file = Tempfile.new('.settings.gradle.tmp', :encoding => 'UTF-8') begin - File.open(settings_file, 'r') do |file| + File.open(settings_file, 'r', :encoding => 'UTF-8') do |file| file.each_line do |line| temp_file.puts(line) end @@ -92,7 +92,7 @@ def update_module_build(build_file, module_name, depend_modules, version_name) dest_path = File.dirname(big_build_file) FileUtils.mkdir_p(dest_path) unless File.exist?(dest_path) - file = File.new(big_build_file, 'w') + file = File.new(big_build_file, 'w', :encoding => 'UTF-8') begin file << result file.close @@ -295,7 +295,7 @@ def recover_bigkeeper_config_file(bigkeeper_config_file) if !File.exist?(bigkeeper_config_file) return end - temp_file = Tempfile.new('.bigkeeper_config.tmp') + temp_file = Tempfile.new('.bigkeeper_config.tmp', :encoding => 'UTF-8') isBigkeeperScript = false isBigkeeperBackupScript = false begin diff --git a/lib/big_keeper/util/podfile_operator.rb b/lib/big_keeper/util/podfile_operator.rb index 0bef2b8..22c1a68 100644 --- a/lib/big_keeper/util/podfile_operator.rb +++ b/lib/big_keeper/util/podfile_operator.rb @@ -36,7 +36,7 @@ def replace_all_module_release(path, user, module_names, version) end def find_and_lock(podfile, dictionary) - temp_file = Tempfile.new('.Podfile.tmp') + temp_file = Tempfile.new('.Podfile.tmp', :encoding => 'UTF-8') begin File.open(podfile, 'r') do |file| file.each_line do |line| @@ -65,9 +65,9 @@ def find_and_lock(podfile, dictionary) end def find_and_upgrade(podfile, dictionary) - temp_file = Tempfile.new('.Podfile.tmp') + temp_file = Tempfile.new('.Podfile.tmp', :encoding => 'UTF-8') begin - File.open(podfile, 'r') do |file| + File.open(podfile, 'r', :encoding => 'UTF-8') do |file| file.each_line do |line| pod_model = PodfileParser.get_pod_model(line) if pod_model != nil && pod_model.name != nil && dictionary[pod_model.name] != nil @@ -87,10 +87,10 @@ def find_and_upgrade(podfile, dictionary) end def podspec_change(podspec_file, version, module_name) - temp_file = Tempfile.new(".#{module_name}.podspec") + temp_file = Tempfile.new(".#{module_name}.podspec", :encoding => 'UTF-8') has_change = false begin - File.open(podspec_file, 'r') do |file| + File.open(podspec_file, 'r', :encoding => 'UTF-8') do |file| file.each_line do |line| if line.include?("s.version") temp_line = line