Sha256: 3280722ac29c689bbd031f84691a9502e437c46037a8cc60bae44036995a3f56

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

require 'thor'
require 'thegarage/gitx'
require 'thegarage/gitx/cli/base_command'
require 'thegarage/gitx/cli/update_command'

module Thegarage
  module Gitx
    module Cli
      class IntegrateCommand < BaseCommand
        desc 'integrate', 'integrate the current branch into one of the aggregate development branches (default = staging)'
        def integrate(target_branch = 'staging')
          branch = current_branch.name
          assert_not_protected_branch!(branch, 'integrate') unless aggregate_branch?(target_branch)
          raise "Only aggregate branches are allowed for integration: #{AGGREGATE_BRANCHES}" unless aggregate_branch?(target_branch) || target_branch == Thegarage::Gitx::BASE_BRANCH

          UpdateCommand.new.update

          say "Integrating "
          say "#{branch} ", :green
          say "into "
          say target_branch, :green

          refresh_branch_from_remote target_branch
          run_cmd "git pull . #{branch}"
          run_cmd "git push origin HEAD"
          run_cmd "git checkout #{branch}"
        end

        private

        # nuke local branch and pull fresh version from remote repo
        def refresh_branch_from_remote(target_branch)
          run_cmd "git branch -D #{target_branch}", :allow_failure => true
          run_cmd "git fetch origin"
          run_cmd "git checkout #{target_branch}"
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thegarage-gitx-2.0.4 lib/thegarage/gitx/cli/integrate_command.rb
thegarage-gitx-2.0.3 lib/thegarage/gitx/cli/integrate_command.rb
thegarage-gitx-2.0.2 lib/thegarage/gitx/cli/integrate_command.rb
thegarage-gitx-2.0.1 lib/thegarage/gitx/cli/integrate_command.rb
thegarage-gitx-2.0.0 lib/thegarage/gitx/cli/integrate_command.rb
thegarage-gitx-2.0.0.pre2 lib/thegarage/gitx/cli/integrate_command.rb
thegarage-gitx-2.0.0.pre1 lib/thegarage/gitx/cli/integrate_command.rb