Sha256: cbc25a81f8ca28d0bd018bdee8e4f6b0d4b492e95601af84313271beddd08a96
Contents?: true
Size: 1.76 KB
Versions: 6
Compression:
Stored size: 1.76 KB
Contents
require 'rubygems/tasks/task' module Gem class Tasks module SCM # # The `scm:status` task. # class Status < Task # # Initializes the `status` task. # # @param [Hash] options # Additional options. # def initialize(options={}) super() yield self if block_given? define end # # Defines the `status` task. # def define namespace :scm do task :status do if dirty? error "Project has uncommitted changes!" status abort end end end # alias the `validate` task to scm:status task :validate => 'scm:status' end # # Checks the status of the project repository. # # @return [Boolean] # Specifies whether the repository is dirty. # # @api semipublic # # @since 0.2.1 # def dirty? status = case @project.scm when :git then `git status --porcelain --untracked-files=no` when :hg then `hg status --quiet` when :svn then `svn status --quiet` else '' end return !status.chomp.empty? end # # Displays the status of the project repository. # # @api semipublic # def status case @project.scm when :git then run 'git', 'status', '--untracked-files=no' when :hg then run 'hg', 'status', '--quiet' when :svn then run 'svn', 'status', '--quiet' end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems