Sha256: 0d604b05d3a5224efe4e6dae49e53e597e6650b1512ca518e32df357687d980e

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 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.2.0 lib/rubygems/tasks/scm/push.rb