Sha256: 131a7d9e7db3f7b4db35a53a37c45ed6158e8d150ef03720fe4c47fc4daf9114

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require_relative 'release_common'

class Jeweler
  module Commands
    class ReleaseToGit
      include ReleaseCommon

      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')
        branch = repo.current_branch
        output.puts "Pushing #{branch} to origin"
        repo.push('origin', branch)
        
        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 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

1 entries across 1 versions & 1 rubygems

Version Path
jeweler2-2.0.9 lib/jeweler/commands/release_to_git.rb