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/init.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/lockfile_parser.rb,
lib/big_keeper/util/verify_operator.rb,
lib/big_keeper/command/release/start.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/finish.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/util/command_line_util.rb,
lib/big_keeper/command/release/publish.rb,
lib/big_keeper/dependency/dep_operator.rb,
lib/big_keeper/util/info_plist_operator.rb,
lib/big_keeper/util/gradle_file_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/util/gradle_module_operator.rb,
lib/big_keeper/command/feature&hotfix/start.rb,
lib/big_keeper/util/version_config_operator.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/util/gradle_content_generator.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, CommandLineUtil, DepGradleOperator, DepOperator, DepPodOperator, DepService, FileOperator, GitOperator, GitService, GitflowOperator, GradleConentGenerator, GradleFileOperator, GradleModuleOperator, InfoPlistOperator, LeanCloudLogger, LibraryModel, ListGenerator, LockfileParser, Logger, ModuleCacheOperator, ModuleService, OCCodeOperator, PodOperator, PodfileModel, PodfileModuleDetector, PodfileOperator, PodfileParser, StashService, VerifyOperator, VersionConfigOperator, XcodeOperator

Constant Summary collapse

VERSION =
"0.9.11"
DEFAULT_LOG =
1
HIGHLIGHT_LOG =
2
ERROR_LOG =
3
WARNING_LOG =
4

Class Method Summary collapse

Class Method Details

.configsObject



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
# 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 |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("#{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
        start(path, version, user, name, modules, type)
      end
    end

    c.desc "Update modules for the #{GitflowType.name(type)} with name"
    c.command :update do |update|
      update.action do |global_options, options, args|
        path = File.expand_path(global_options[:path])
        user = global_options[: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 |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("#{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 |global_options, options, args|
        path = File.expand_path(global_options[:path])
        user = global_options[: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 |global_options, options, args|
        path = File.expand_path(global_options[:path])
        user = global_options[: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 |global_options, options, args|
        path = File.expand_path(global_options[:path])
        user = global_options[: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 |global_options, options, args|
        path = File.expand_path(global_options[:path])
        user = global_options[: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 |global_options, options, args|
        path = File.expand_path(global_options[:path])
        user = global_options[: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 |global_options, options, args|
        path = File.expand_path(global_options[:path])
        user = global_options[: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 |global_options, options, 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.expand_path(global_options[:path])
          user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
          list(path, user, type, options)
        end
      end

      list.desc "Print list of JSON format."
      list.command :json do |json|
        json.action do |global_options, options, args|
          LeanCloudLogger.instance.set_command("#{GitflowType.command(type)}/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, type, options)
        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
# 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")

    branch_name = GitOperator.new.current_branch(path)
    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).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(modules, OperateType::FINISH, false)

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

    # Push home changes to remote
    GitService.new.verify_push(path, "finish branch #{branch_name}", 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(options, file_path, version, home_branches)
  if options[: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.expand_path("#{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_commandObject



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 | global_options, options, args |
        LeanCloudLogger.instance.set_command("image/name")

        path = File.expand_path(global_options[: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 | global_options, options, args |
        LeanCloudLogger.instance.set_command("image/content")
        path = File.expand_path(global_options[:path])
        BigResources::ImageAnalyzeUtil.get_duplicate_content_file_with_type(path, BigResources::PNG)
      end
    end
  end
end

.init_commandObject



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
# File 'lib/big_keeper/command/init.rb', line 7

def self.init_command
  desc 'BigKeeper file initialize'
  command :init do | c |
    c.desc "BigKeeper template file initialize."
    c.action do | global_options, options, args |
      LeanCloudLogger.instance.set_command("big/init")

      bin_path = File.dirname(__FILE__)
      bin_path = File.dirname(bin_path)
      bin_path = File.dirname(bin_path)
      bin_path = File.dirname(bin_path)
      path = global_options['path']
      Logger.highlight("Initialize BigKeeper File...")
      #template path
      source_file = File.join(bin_path, 'resources/template/BigKeeper')
      #BigKeeper file need exist path
      target_path = File.join(path, 'BigKeeper')

      if !File.exists?(target_path)
        FileUtils.cp(source_file, target_path)
        Logger.highlight("Initialize BigKeeper Complete!")
      else
        Logger.highlight("BigKeeper File Has Exist!")
      end

      LeanCloudLogger.instance.set_command("file/init")
    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, options)
  BigkeeperParser.parse("#{path}/Bigkeeper")
  home_path = File.expand_path(path)
  #get home project branches
  branches = GitService.new.branchs_with_type(home_path, type)
  #get modules list
  is_print_log = false if options[:json]
  #get search version
  version = options[:version]
  cache_path = File.expand_path("#{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(options, 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

.modulesObject



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_commandObject



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
# 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 |global_options, options, args|
        LeanCloudLogger.instance.set_command("podfile/detect")

        path = File.expand_path(global_options[:path])
        podfile_detect(path)
      end
    end

    podfile.desc 'Lock podname should be locked.'
    podfile.command :lock do |lock|
      lock.desc 'Lock pods accouding to Podfile.'
      lock.command :module do |m|
        m.action do |global_options, options, args|
          LeanCloudLogger.instance.set_command("podfile/lock/module")

          path = File.expand_path(global_options[:path])
          podfile_lock(path, false)
        end
      end
      lock.desc 'Lock pods accouding to Podfile.lock.'
      lock.command :submodule do |s|
        s.action do |global_options, options, args|
          LeanCloudLogger.instance.set_command("podfile/lock/submodule")

          path = File.expand_path(global_options[:path])
          podfile_lock(path, true)
        end
      end

    end

    podfile.desc 'Update modules should be upgrade.'
    podfile.command :update do |update|
      update.action do |global_options, options, args|
        LeanCloudLogger.instance.set_command("podfile/update")

        path = File.expand_path(global_options[:path])
        podfile_modules_update(path)
      end
    end
  end
end

.podfile_detect(path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/big_keeper/command/pod/podfile.rb', line 12

def self.podfile_detect(path)
    # Parse Bigkeeper file
    BigkeeperParser.parse("#{path}/Bigkeeper")
    # Get modules' name
    # module_list = BigkeeperParser.module_names
    # initialize PodfileDetector
    detector = PodfileParser.instance
    detactor.parse
    # 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, is_all) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/big_keeper/command/pod/podfile.rb', line 30

def self.podfile_lock(path, is_all)
    # Parse Bigkeeper file
    BigkeeperParser.parse("#{path}/Bigkeeper")
    # initialize PodfileDetector
    pod_parser = PodfileParser.instance
    #Parser Podfile.lock
    pod_parser.parse(path)
    #initialize LockfileParser
    lock_parser = LockfileParser.instance
    #Parser Podfile.lock
    lock_parser.parse(path)
    # Get unlocked third party pods list
    unlock_pod_info = lock_parser.get_unlock_pod_list(is_all)
    # Lock modules in podfile
    if unlock_pod_info.empty?
      Logger.warning("There is nothing to be locked.")
    else
      PodfileOperator.new.find_and_lock("#{path}/Podfile", unlock_pod_info)
      Logger.highlight("The Podfile has been changed.")
      Logger.separator
    end

end

.podfile_modules_update(path) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/big_keeper/command/pod/podfile.rb', line 54

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



2
3
# File 'lib/big_keeper/command/release/publish.rb', line 2

def self.publish(path, version, user)
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_check_changed_modules(path, user) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/big_keeper/command/release/start.rb', line 67

def self.release_check_changed_modules(path, user)
  changed_modules = []
  BigkeeperParser.parse("#{path}/Bigkeeper")
  allModules = BigkeeperParser.module_names
  allModules.each do |module_name|
    if ModuleService.new.release_check_changed(path, user, module_name)
      changed_modules << module_name
    end
  end
  changed_modules
end

.release_commandObject



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
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/big_keeper/command/release.rb', line 9

def self.release_command
  desc 'Gitflow release operations'
  command :release do |c|

    c.desc 'release project start'
    c.command :start do |start|
      start.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
        modules = args[(0...args.length)] if args.length > 0
        release_start(path, version, user, modules)
      end
    end

    c.desc 'release project finish'
    c.command :finish do |finish|
      finish.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
        modules = args[(0...args.length)] if args.length > 0
        release_finish(path, version, user, modules)
      end
    end

    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 |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("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 |global_options, options, args|
          path = File.expand_path(global_options[:path])
          version = global_options[: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 |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("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, options[:ignore])
        end
      end

      m.desc 'finish release module project'
      m.switch [:s,:spec]
      m.command :finish do |finish|
        finish.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("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, options[:spec])
        end
      end
    end
  end
end

.release_finish(path, version, user, modules) ⇒ Object



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
# File 'lib/big_keeper/command/release/start.rb', line 39

def self.release_finish(path, version, user, modules)
  BigkeeperParser.parse("#{path}/Bigkeeper")
  version = BigkeeperParser.version if version == 'Version in Bigkeeper file'

  #stash home
  StashService.new.stash(path, GitOperator.new.current_branch(path), 'home')
  # delete cache
  CacheOperator.new(path).clean()
  # checkout develop
  GitService.new.verify_checkout_pull(path, 'develop')

  modules.each do |module_name|
    Logger.highlight("release start module #{module_name}")
    ModuleService.new.release_finish(path, user, modules, module_name, version)
  end

  #release home
  DepService.dep_operator(path, user).release_home_finish(modules, version)

  # Push home changes to remote
  Logger.highlight("Push branch 'develop' for 'Home'...")
  GitService.new.verify_push(
    path,
    "release finish for #{version}",
    'develop',
    'Home')
end

.release_home_finish(path, version) ⇒ Object



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
# File 'lib/big_keeper/command/release/home.rb', line 54

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



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
# File 'lib/big_keeper/command/release/home.rb', line 11

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(modules, OperateType::RELEASE, true)
  XcodeOperator.open_workspace(path)
end

.release_module_finish(path, version, user, module_name, spec) ⇒ Object

release finish



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/release/module.rb', line 35

def self.release_module_finish(path, version, user, module_name, spec)
  BigkeeperParser.parse("#{path}/Bigkeeper")

  version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
  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
31
32
# 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")

  version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
  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

.release_start(path, version, user, modules) ⇒ Object



2
3
4
5
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
# File 'lib/big_keeper/command/release/start.rb', line 2

def self.release_start(path, version, user, modules)
  BigkeeperParser.parse("#{path}/Bigkeeper")
  version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
  modules = release_check_changed_modules(path, user) if (modules.nil? || modules.empty?)

  if modules.nil? || modules.empty?
    Logger.error('no module need to release')
  end

  if !CommandLineUtil.double_check("module #{modules} will changed version to #{version}-SNAPSHOT, are you sure?")
    Logger.error('release start interrupt')
  end

  #stash home
  StashService.new.stash(path, GitOperator.new.current_branch(path), 'home')
  # delete cache
  CacheOperator.new(path).clean()
  # checkout develop
  GitService.new.verify_checkout_pull(path, 'develop')

  modules.each do |module_name|
    Logger.highlight("release start module #{module_name}")
    ModuleService.new.release_start(path, user, modules, module_name, version)
  end

  #release home
  DepService.dep_operator(path, user).release_home_start(modules, version)

  # Push home changes to remote
  Logger.highlight("Push branch 'develop' for 'Home'...")
  GitService.new.verify_push(
    path,
    "release start for #{version}",
    'develop',
    'Home')
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_addObject



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_commandObject



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 |global_options, options, args|
        LeanCloudLogger.instance.set_command("spec/analyze")

        path = File.expand_path(global_options[:path])
        is_all = options[: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 |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

    spec.desc 'Sync Module dependency from Home.'
    spec.command :sync do | sync|
      sync.action do |global_options, options, args|
        LeanCloudLogger.instance.set_command("spec/sync")

        path = File.expand_path(global_options[:path])
        version = global_options[:ver]
        user = global_options[: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_deleteObject



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, options)
    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_searchObject



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, name, 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/start.rb', line 20

def self.start(path, version, user, name, modules, type)
  begin
    # Parse Bigkeeper file
    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 = ModuleCacheOperator.new(path).all_path_modules

    # Stash current branch
    StashService.new.stash_all(path, branch_name, user, stash_modules)

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

    Logger.highlight("Add branch '#{branch_name}' for 'Home'...")
    # Start home feature
    GitService.new.start(path, full_name, type)

    # Clean module cache
    ModuleCacheOperator.new(path).clean_modules

    # Cache all path modules
    ModuleCacheOperator.new(path).cache_path_modules(modules, modules, [])
    modules = ModuleCacheOperator.new(path).remain_path_modules

    # Backup home
    DepService.dep_operator(path, user).backup

    # Start modules feature and modify module as path
    modules.each do |module_name|
      ModuleService.new.add(path, user, module_name, full_name, type)
    end

    # install
    DepService.dep_operator(path, user).install(modules, OperateType::START, true)

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

    # Push home changes to remote
    Logger.highlight("Push branch '#{branch_name}' for 'Home'...")
    GitService.new.verify_push(
      path,
      "init #{GitflowType.name(type)} #{full_name}",
      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
# 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
    BigkeeperParser.parse("#{path}/Bigkeeper")

    version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
    branch_name = "#{GitflowType.name(type)}/#{full_name}"

    GitService.new.verify_home_branch(path, branch_name, OperateType::SWITCH)

    stash_modules = ModuleCacheOperator.new(path).all_path_modules

    # Stash current branch
    StashService.new.stash_all(path, branch_name, user, stash_modules)

    # Switch to new feature
    GitOperator.new.checkout(path, branch_name)
    GitOperator.new.pull(path)

    # Apply home stash
    StashService.new.pop_stash(path, branch_name, 'Home')

    modules = ModuleCacheOperator.new(path).all_path_modules

    modules.each do |module_name|
      ModuleService.new.switch_to(path, user, module_name, branch_name, type)
    end

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

    # 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
# 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")
    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)

    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
      # 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(modules, OperateType::UPDATE, false)

    # Open home workspace
    DepService.dep_operator(path, user).open
  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