class Jeweler::Commands::ReleaseToGit
Attributes
base_dir[RW]
gemspec[RW]
gemspec_helper[RW]
output[RW]
repo[RW]
version[RW]
Public Class Methods
build_for(jeweler)
click to toggle source
# File lib/jeweler/commands/release_to_git.rb, line 50 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
new(attributes = {})
click to toggle source
# File lib/jeweler/commands/release_to_git.rb, line 6 def initialize(attributes = {}) self.output = $stdout attributes.each_pair do |key, value| send("#{key}=", value) end end
Public Instance Methods
clean_staging_area?()
click to toggle source
# File lib/jeweler/commands/release_to_git.rb, line 37 def clean_staging_area? %x`git ls-files --deleted --modified --others --exclude-standard` == "" end
release_not_tagged?()
click to toggle source
# File lib/jeweler/commands/release_to_git.rb, line 45 def release_not_tagged? tag = repo.tag(release_tag) rescue nil tag.nil? end
release_tag()
click to toggle source
# File lib/jeweler/commands/release_to_git.rb, line 41 def release_tag "v#{version}" end
run(args = {})
click to toggle source
# File lib/jeweler/commands/release_to_git.rb, line 14 def run(args = {}) remote = args[:remote] || 'origin' branch = args[:branch] || 'master' local_branch = args[:local_branch] || branch remote_branch = args[:remote_branch] || branch 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(local_branch) repo.push(remote, "#{local_branch}:#{remote_branch}") if release_not_tagged? output.puts "Tagging #{release_tag}" repo.add_tag(release_tag) output.puts "Pushing #{release_tag} to #{remote}" repo.push(remote, release_tag) end end