Sha256: 14fae9525d073758f5d673450ef5636973307dff86378444244975d3036e24c3

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 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
          namespace :scm do
            task :push 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.
        #
        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

1 entries across 1 versions & 1 rubygems

Version Path
rubygems-tasks-0.1.2 lib/rubygems/tasks/scm/push.rb