Sha256: 689498323c9bb1ffd790a7af74bcb43d8add5c2d821bf2d50279eda760c7e193

Contents?: true

Size: 1.42 KB

Versions: 104

Compression:

Stored size: 1.42 KB

Contents

class Jeweler
  module Commands
    class ReleaseToGit
      attr_accessor :gemspec, :version, :repo, :output, :gemspec_helper, :base_dir

      def initialize(attributes = {})
        self.output = $stdout

        attributes.each_pair do |key, value|
          send("#{key}=", value)
        end
      end

      def run
        unless clean_staging_area?
          system "git status"
          raise "Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above."
        end

        repo.checkout('master')
        repo.push
        
        if release_not_tagged?
          output.puts "Tagging #{release_tag}"
          repo.add_tag(release_tag)

          output.puts "Pushing #{release_tag} to origin"
          repo.push('origin', release_tag)
        end
      end

      def clean_staging_area?
        `git ls-files --deleted --modified --others --exclude-standard` == ""
      end

      def release_tag
        "v#{version}"
      end

      def release_not_tagged?
        tag = repo.tag(release_tag) rescue nil
        tag.nil?
      end

      def self.build_for(jeweler)
        command = self.new

        command.base_dir = jeweler.base_dir
        command.gemspec = jeweler.gemspec
        command.version = jeweler.version
        command.repo = jeweler.repo
        command.output = jeweler.output
        command.gemspec_helper = jeweler.gemspec_helper

        command
      end
    end
  end
end

Version data entries

104 entries across 50 versions & 5 rubygems

Version Path
jeweler-1.8.8 lib/jeweler/commands/release_to_git.rb
jeweler-1.8.7 lib/jeweler/commands/release_to_git.rb
jeweler-1.8.6 lib/jeweler/commands/release_to_git.rb
jeweler-1.8.5 lib/jeweler/commands/release_to_git.rb
devise_sociable-0.1.0 vendor/bundle/gems/jeweler-1.8.4/lib/jeweler/commands/release_to_git.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/release_to_git.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/release_to_git.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/release_to_git.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/release_to_git.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/release_to_git.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/release_to_git.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/release_to_git.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/release_to_git.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/release_to_git.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/release_to_git.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/release_to_git.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/release_to_git.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/release_to_git.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/release_to_git.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/release_to_git.rb