Skip to content

Commit

Permalink
Merge pull request #39 from BigKeeper/develop
Browse files Browse the repository at this point in the history
merge develop to master
  • Loading branch information
sfmDev authored Oct 11, 2019
2 parents ad45a15 + 2203431 commit ec72be3
Show file tree
Hide file tree
Showing 32 changed files with 830 additions and 353 deletions.
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 17 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bigkeeper (0.9.9)
bigkeeper (0.9.17)
big_resources
big_stash (~> 0.1)
cocoapods
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion lib/big_keeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -46,7 +47,7 @@ module BigKeeper

post do |global_options, command, options, args|
is_show_log = true
if global_options[:log] == 'false'
if global_options[:log] == 'true'
is_show_log = false
end
LeanCloudLogger.instance.end_log(true, is_show_log)
Expand All @@ -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|
Expand Down
50 changes: 50 additions & 0 deletions lib/big_keeper/command/client.rb
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions lib/big_keeper/command/feature&hotfix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require 'big_keeper/command/feature&hotfix/publish'
require 'big_keeper/command/feature&hotfix/delete'
require 'big_keeper/command/feature&hotfix/list'
require 'big_keeper/command/feature&hotfix/module'
require 'big_keeper/util/leancloud_logger'

module BigKeeper
Expand Down Expand Up @@ -43,6 +44,33 @@ def self.feature_and_hotfix_command(type)
end
end

c.desc "Modules operate for the #{GitflowType.name(type)}"
c.command :module do |m|
m.desc "Add modules for the #{GitflowType.name(type)}"
m.command :add do |add|
add.action do |global_options, options, args|
path = File.expand_path(global_options[:path])
version = global_options[:ver]
user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
LeanCloudLogger.instance.set_command("feature/module/add")
modules = args[(0...args.length)] if args.length > 0
module_add(path, user, modules, type)
end
end

m.desc "delete modules for the #{GitflowType.name(type)}"
m.command :delete do |delete|
delete.action do |global_options, options, args|
path = File.expand_path(global_options[:path])
version = global_options[:ver]
user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
LeanCloudLogger.instance.set_command("feature/module/delete")
modules = args[(0...args.length)] if args.length > 0
module_del(path, user, modules, type)
end
end
end

c.desc "Switch to the #{GitflowType.name(type)} with name"
c.command :switch do |switch|
switch.action do |global_options, options, args|
Expand Down
2 changes: 1 addition & 1 deletion lib/big_keeper/command/feature&hotfix/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion lib/big_keeper/command/feature&hotfix/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
89 changes: 89 additions & 0 deletions lib/big_keeper/command/feature&hotfix/module.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/ruby

require 'big_keeper/util/podfile_operator'
require 'big_keeper/util/gitflow_operator'
require 'big_keeper/util/bigkeeper_parser'
require 'big_keeper/util/logger'
require 'big_keeper/util/pod_operator'
require 'big_keeper/util/xcode_operator'
require 'big_keeper/util/cache_operator'
require 'big_keeper/model/operate_type'
require 'big_keeper/dependency/dep_service'

require 'big_keeper/dependency/dep_type'

require 'big_keeper/service/stash_service'
require 'big_keeper/service/module_service'


module BigKeeper
def self.module_add(path, user, modules, type)
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)}\//, '')

# Verify input modules
modules = BigkeeperParser.verify_modules(modules)

current_modules = ModuleCacheOperator.new(path).current_path_modules

ModuleCacheOperator.new(path).clean_modules
ModuleCacheOperator.new(path).cache_path_modules(current_modules + modules, modules, [])

Logger.highlight("Start to add modules for branch '#{branch_name}'...")

if modules.empty?
Logger.default("There is nothing changed with modules #{modules}.")
else
# Modify podfile as path and Start modules feature
modules.each do |module_name|
ModuleCacheOperator.new(path).add_path_module(module_name)
ModuleService.new.add(path, user, module_name, full_name, type)
end
end

# Install
DepService.dep_operator(path, user).install(modules, OperateType::UPDATE, false)

# Open home workspace
DepService.dep_operator(path, user).open
end

def self.module_del(path, user, modules, type)
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 = ModuleCacheOperator.new(path).current_path_modules

# Verify input modules
modules = BigkeeperParser.verify_modules(modules)

ModuleCacheOperator.new(path).clean_modules
ModuleCacheOperator.new(path).cache_path_modules(current_module + modules, [], modules)

Logger.highlight("Start to delete modules for branch '#{branch_name}'...")

if modules.empty?
Logger.default("There is nothing changed with modules #{modules}.")
else
# Modify podfile as path and Start modules feature
modules.each do |module_name|
ModuleCacheOperator.new(path).del_path_module(module_name)
ModuleService.new.del(path, user, module_name, full_name, type)
end
end

# Install
DepService.dep_operator(path, user).install(modules, OperateType::UPDATE, false)

# Open home workspace
DepService.dep_operator(path, user).open
end
end
17 changes: 15 additions & 2 deletions lib/big_keeper/command/feature&hotfix/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,28 @@ def self.publish(path, user, type)

Logger.highlight("Publish branch '#{branch_name}' for 'Home'")

# [CHG] try to fix publish bug
# Recover home
DepService.dep_operator(path, user).recover
# 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()}`
current_cmd = LeanCloudLogger.instance.command
cmds = BigkeeperParser.post_install_command

if cmds && (cmds.keys.include? current_cmd)
cmd = BigkeeperParser.post_install_command[current_cmd]
if path
Dir.chdir(path) do
system cmd
end
end
else
`open #{BigkeeperParser.home_pulls()}`
end
ensure
end
end
Expand Down
Loading

0 comments on commit ec72be3

Please sign in to comment.