Sha256: 68edd953129cec628017b33b718e0c00b3fecced0333cd4d1e3a46b9666ec4f8

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 KB

Contents

require 'rgitflow/tasks/task'

module RGitFlow
  module Tasks
    class Feature
      class Start < RGitFlow::Tasks::Task
        def initialize(git)
          super(git, 'start', 'Start a feature branch', ['rgitflow', 'feature'])
        end

        protected

        def run
          status 'Starting feature branch...'

          unless @git.current_branch == RGitFlow::Config.options[:develop]
            error 'Cannot create feature branch unless on development branch'
            abort
          end

          branch = ENV['BRANCH']

          while branch.blank?
            error 'Cannot create a branch with an empty name!'
            prompt 'Please enter a name for your feature branch:'
            branch = STDIN.gets.chomp
          end

          branch = [RGitFlow::Config.options[:feature], branch].join('/')

          if @git.is_local_branch? branch
            error 'Cannot create a branch that already exists locally'
            abort
          end

          if @git.is_remote_branch? branch
            error 'Cannot create a branch that already exists remotely'
            abort
          end

          @git.branch(branch).create
          @git.branch(branch).checkout

          status "Started feature branch #{branch}!"
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rgitflow-0.2.2 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.1.pre.alpha.pre.32 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.1.pre.alpha.pre.28 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.0.pre.alpha.pre.27 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.0.pre.alpha.pre.26 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.0.pre.alpha.pre.25 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.0 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.0.pre.alpha.pre.23 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.0.pre.alpha.pre.22 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.0.pre.alpha.pre.21 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.2.0.pre.alpha.pre.20 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.1.0 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.1.0.pre.alpha.pre.18 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.1.0.pre.alpha.pre.17 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.1.0.pre.alpha.pre.16 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.1.0.pre.alpha.pre.15 lib/rgitflow/tasks/feature/start.rb
rgitflow-0.1.0.pre.alpha.pre.14 lib/rgitflow/tasks/feature/start.rb