Module: BigKeeper

Defined in:
lib/big_keeper/command/release_home.rb,
lib/big_keeper.rb,
lib/big_keeper/version.rb,
lib/big_keeper/util/git_operator.rb,
lib/big_keeper/model/gitflow_type.rb,
lib/big_keeper/model/operate_type.rb,
lib/big_keeper/model/podfile_type.rb,
lib/big_keeper/service/git_service.rb,
lib/big_keeper/command/feature_pull.rb,
lib/big_keeper/command/feature_push.rb,
lib/big_keeper/command/podfile_lock.rb,
lib/big_keeper/command/feature_start.rb,
lib/big_keeper/service/stash_service.rb,
lib/big_keeper/util/bigkeeper_parser.rb,
lib/big_keeper/util/gitflow_operator.rb,
lib/big_keeper/util/podfile_operator.rb,
lib/big_keeper/command/feature_finish.rb,
lib/big_keeper/command/feature_switch.rb,
lib/big_keeper/command/feature_update.rb,
lib/big_keeper/command/release_module.rb,
lib/big_keeper/service/module_service.rb,
lib/big_keeper/util/info_plist_operator.rb

Overview

替换当前 podfile 中某个 module 为 pod #module_name, :git => ‘#sourcesource.base’, :tag => ‘#sourcesource.addition’

Defined Under Namespace

Modules: GitType, GitflowType, ModuleType, OperateType Classes: BigkeeperParser, GitInfo, GitOperator, GitService, GitflowOperator, InfoPlistOperator, ModuleService, PodfileOperator, StashService

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.feature_finish(path, 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
# File 'lib/big_keeper/command/feature_finish.rb', line 10

def self.feature_finish(path, user)
  begin
    # Parse Bigkeeper file
    BigkeeperParser.parse("#{path}/Bigkeeper")

    modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
                              BigkeeperParser.module_names, ModuleType::PATH)

    branch_name = GitOperator.new.current_branch(path)
    raise "Not a feature branch, exit." unless branch_name.include? 'feature'

    # Rebase modules and modify podfile as git
    modules.each do |module_name|
      ModuleService.new.finish(path, user, module_name)
    end

    BigkeeperParser.module_names.each do |module_name|
      module_git = BigkeeperParser.module_git(module_name)
      PodfileOperator.new.find_and_replace("#{path}/Podfile",
                                           module_name,
                                           ModuleType::GIT,
                                           GitInfo.new(module_git, GitType::BRANCH, 'develop'))
    end

    # pod install
    p `pod install --project-directory=#{path}`

    # Push home changes to remote
    GitOperator.new.commit(path, "finish #{GitflowType.name(GitflowType::FEATURE)} #{branch_name}")
    GitOperator.new.push(path, branch_name)

    GitService.new.verify_rebase(path, 'develop', 'Home')

    `open #{BigkeeperParser.home_pulls()}`
  ensure
  end
end

.feature_pull(path, user) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/big_keeper/command/feature_pull.rb', line 2

def self.feature_pull(path, user)
  begin
    # Parse Bigkeeper file
    BigkeeperParser.parse("#{path}/Bigkeeper")

    branch_name = GitOperator.new.current_branch(path)
    raise 'Not a feature branch, exit.' unless branch_name.include? 'feature'

    modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
                                                    BigkeeperParser.module_names, ModuleType::PATH)

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

    p 'Start pulling home...'
    GitOperator.new.pull(path, branch_name)
    p 'Finish pulling home...'
  ensure
  end
end

.feature_push(path, user, comment) ⇒ Object



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

def self.feature_push(path, user, comment)
  begin
    # Parse Bigkeeper file
    BigkeeperParser.parse("#{path}/Bigkeeper")

    branch_name = GitOperator.new.current_branch(path)
    raise "Not a feature branch, exit." unless branch_name.include? 'feature'

    modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
                              BigkeeperParser.module_names, ModuleType::PATH)

    modules.each do |module_name|
      module_full_path = BigkeeperParser.module_full_path(path, user, module_name)
      module_branch_name = GitOperator.new.current_branch(module_full_path)

      if GitOperator.new.has_changes(module_full_path)
        p "Start pushing #{module_name}..."
        GitOperator.new.commit(module_full_path, comment)
        GitOperator.new.push(module_full_path, module_branch_name)
        p "Finish pushing #{module_name}..."
      else
        p "Nothing to push for #{module_name}."
      end
    end

    if GitOperator.new.has_changes(path)
      p "Start pushing home..."
      GitOperator.new.commit(path, comment)
      GitOperator.new.push(path, branch_name)
      p "Finish pushing home..."
    else
      p "Nothing to push for home."
    end
  ensure
  end
end

.feature_start(path, version, user, name, modules) ⇒ 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
# File 'lib/big_keeper/command/feature_start.rb', line 14

def self.feature_start(path, version, user, name, modules)
  begin
    # Parse Bigkeeper file
    BigkeeperParser.parse("#{path}/Bigkeeper")

    version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
    feature_name = "#{version}_#{user}_#{name}"
    branch_name = "#{GitflowType.name(GitflowType::FEATURE)}/#{feature_name}"

    GitService.new.verify_branch(path, branch_name, OperateType::START)

    stash_modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
                              BigkeeperParser.module_names, ModuleType::PATH)

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

    # Handle modules
    if modules
      # Verify input modules
      BigkeeperParser.verify_modules(modules)
    else
      # Get all modules if not specified
      modules = BigkeeperParser.module_names
    end

    # Start home feature
    GitOperator.new.git_checkout(path, 'master') if GitOperator.new.has_remote_branch(path, 'master')
    GitOperator.new.git_checkout(path, 'develop') if GitOperator.new.has_remote_branch(path, 'develop')

    GitOperator.new.pull(path, 'develop') if GitOperator.new.has_remote_branch(path, 'develop')

    GitflowOperator.new.start(path, feature_name, GitflowType::FEATURE)

    # Modify podfile as path and Start modules feature
    modules.each do |module_name|
      ModuleService.new.add(path, user, module_name, feature_name, GitflowType::FEATURE)
    end

    # pod install
    p `pod install --project-directory=#{path}`

    # Push home changes to remote
    GitOperator.new.commit(path, "init #{GitflowType.name(GitflowType::FEATURE)} #{feature_name}")
    GitOperator.new.push(path, branch_name)

    # Open home workspace
    `open #{path}/*.xcworkspace`
  ensure
  end
end

.feature_switch(path, version, user, name) ⇒ Object



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
38
39
40
41
42
# File 'lib/big_keeper/command/feature_switch.rb', line 4

def self.feature_switch(path, version, user, name)
  begin
    # Parse Bigkeeper file
    BigkeeperParser.parse("#{path}/Bigkeeper")

    version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
    feature_name = "#{version}_#{user}_#{name}"
    branch_name = "#{GitflowType.name(GitflowType::FEATURE)}/#{feature_name}"

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

    stath_modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
                              BigkeeperParser.module_names, ModuleType::PATH)

    # Stash current branch
    StashService.new.stash(path, branch_name, user, stath_modules)

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

    modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
                              BigkeeperParser.module_names, ModuleType::PATH)

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

    # Apply stash
    StashService.new.apply_stash(path, branch_name, user, modules)

    # pod install
    p `pod install --project-directory=#{path}`

    # Open home workspace
    `open #{path}/*.xcworkspace`
  ensure
  end
end

.feature_update(path, user, modules) ⇒ 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
# File 'lib/big_keeper/command/feature_update.rb', line 14

def self.feature_update(path, user, modules)
  begin
    # Parse Bigkeeper file
    BigkeeperParser.parse("#{path}/Bigkeeper")

    branch_name = GitOperator.new.current_branch(path)
    raise "Not a feature branch, exit." unless branch_name.include? 'feature'

    feature_name = branch_name.gsub(/feature\//, '')

    current_modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
                              BigkeeperParser.module_names, ModuleType::PATH)

    # Handle modules
    if modules
      # Verify input modules
      BigkeeperParser.verify_modules(modules)
    else
      # Get all modules if not specified
      modules = BigkeeperParser.module_names
    end

    add_modules = modules - current_modules
    del_modules = current_modules - modules

    if add_modules.empty? and del_modules.empty?
      p "There is nothing changed with modules #{modules}."
    else
      # Modify podfile as path and Start modules feature
      add_modules.each do |module_name|
        ModuleService.new.add(path, user, module_name, feature_name, GitflowType::FEATURE)
      end

      del_modules.each do |module_name|
        ModuleService.new.del(path, user, module_name, feature_name, GitflowType::FEATURE)
      end

      # pod install
      p `pod install --project-directory=#{path}`

      # Open home workspace
      `open #{path}/*.xcworkspace`
    end
  ensure
  end
end

.home(name, params) ⇒ Object



12
13
14
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 12

def self.home(name, params)
  BigkeeperParser.parse_home(name, params)
end

.modulesObject



20
21
22
23
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 20

def self.modules
  BigkeeperParser.parse_modules
  yield if block_given?
end

.pod(name, params) ⇒ Object



16
17
18
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 16

def self.pod(name, params)
  BigkeeperParser.parse_pod(name, params)
end

.podfile_lock(path) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/big_keeper/command/podfile_lock.rb', line 8

def self.podfile_lock(path)
  begin
    # Parse Bigkeeper file
    BigkeeperParser.parse("#{path}/Bigkeeper")
    unlock_pod_list = PodfileDetector.new.get_unlock_pod_list
    p unlock_pod_list
  end
end

.release_home_finish(path, version) ⇒ Object



17
18
19
20
21
22
# File 'lib/big_keeper/command/release_home.rb', line 17

def self.release_home_finish(path, version)
  GitOperator.new.commit(path, "release: V #{version}")
  GitOperator.new.push(path, "release/#{version}")
  GitflowOperator.new.finish_release(path, version)
  GitOperator.new.tag(path, version)
end

.release_home_start(path, version, user) ⇒ Object



12
13
14
15
# File 'lib/big_keeper/command/release_home.rb', line 12

def self.release_home_start(path, version, user)
  BigkeeperParser.parse("#{path}/Bigkeeper")
  start_release(path, version, BigkeeperParser::module_names, GitInfo.new(BigkeeperParser::home_git, GitType::TAG, version), user)
end

.start_module_release(path, module_name) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/big_keeper/command/release_module.rb', line 10

def self.start_module_release(path, module_name)
  BigkeeperParser.parse("#{path}/Bigkeeper")

  module_release(path,
          module_name,
          GitInfo.new(BigkeeperParser.home_git, GitType::BRANCH, 'develop'))
end

.user(name) ⇒ Object



7
8
9
10
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 7

def self.user(name)
  BigkeeperParser.parse_user(name)
  yield if block_given?
end

.version(name) ⇒ Object



3
4
5
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 3

def self.version(name)
  BigkeeperParser.parse_version(name)
end