Sha256: c34e437e48b062a1db1673a6140885617f15452a2e91659ec475fccf5470e421

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

require 'rubygems/tasks/task'

module Gem
  class Tasks
    module SCM
      #
      # The `scm:push` task.
      #
      class Push < Task

        #
        # Initializes the `scm:push` task.
        #
        # @param [Hash] options
        #   Additional options.
        #
        def initialize(options={})
          super()

          yield self if block_given?
          define
        end

        #
        # Defines the `scm:push` task.
        #
        def define
          task :validate

          namespace :scm do
            task :push => :validate do
              status "Pushing commits ..."

              unless push!
                error "Could not push commits"
              end
            end
          end
        end

        #
        # Pushes commits.
        #
        # @return [Boolean]
        #   Specifies whether the commits were successfully pushed.
        #
        # @api semipublic
        #
        def push!
          case @project.scm
          when :git
            run 'git', 'push'
            run 'git', 'push', '--tags'
          when :hg 
            run 'hg', 'push'
          else
            true
          end
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubygems-tasks-0.2.6 lib/rubygems/tasks/scm/push.rb
rubygems-tasks-0.2.5 lib/rubygems/tasks/scm/push.rb
rubygems-tasks-0.2.4 lib/rubygems/tasks/scm/push.rb
rubygems-tasks-0.2.3 lib/rubygems/tasks/scm/push.rb
rubygems-tasks-0.2.2 lib/rubygems/tasks/scm/push.rb
rubygems-tasks-0.2.1 lib/rubygems/tasks/scm/push.rb