Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tasks for creating and deleting git tags.
- Loading branch information
Showing
5 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
|
||
require 'net/smtp' | ||
require 'time' | ||
|
||
module Bones::Plugins::Ann | ||
include ::Bones::Helpers | ||
extend self | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
module Bones::Plugins::Git | ||
include ::Bones::Helpers | ||
extend self | ||
|
||
def post_load | ||
have?(:git) { | ||
Dir.entries(Dir.pwd).include?('.git') and | ||
system("git --version 2>&1 > #{DEV_NULL}") | ||
} | ||
end | ||
|
||
def define_tasks | ||
return unless have? :git | ||
|
||
config = ::Bones.config | ||
namespace :git do | ||
|
||
# A prerequisites task that all other tasks depend upon | ||
task :prereqs | ||
|
||
desc 'Show tags from the git repository' | ||
task :tags => 'git:prereqs' do |t| | ||
puts Git.open('.').tags.map {|t| t.name}.reverse | ||
end | ||
|
||
desc 'Create a new tag in the git repository' | ||
task :create_tag => 'git:prereqs' do |t| | ||
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z' | ||
abort "Versions don't match #{v} vs #{config.version}" if v != config.version | ||
|
||
git = Git.open '.' | ||
tag = "%s-%s" % [config.name, config.version] | ||
puts "Creating git tag '#{tag}'." | ||
|
||
begin | ||
git.add_tag tag | ||
rescue Git::GitExecuteError | ||
abort "Tag creation failed: tag '#{tag}' already exists." | ||
end | ||
|
||
if git.remotes.map {|r| r.name}.include? 'origin' | ||
unless system "git push origin #{tag}" | ||
abort "Could not push tag to remote git repository." | ||
end | ||
end | ||
end # task | ||
|
||
desc 'Delete a tag from the git repository' | ||
task :delete_tag => 'git:prereqs' do |t| | ||
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z' | ||
|
||
git = Git.open '.' | ||
tag = "%s-%s" % [config.name, v] | ||
|
||
unless git.tags.map {|t| t.name}.include? tag | ||
puts "Tag '#{tag}' does not exist." | ||
break | ||
end | ||
|
||
puts "Deleting git tag '#{tag}'." | ||
abort 'Tag deletion failed.' unless system "git tag -d '#{tag}'" | ||
|
||
if git.remotes.map {|r| r.name}.include? 'origin' | ||
unless system "git push origin ':refs/tags/#{tag}'" | ||
abort "Could not delete tag from remote git repository." | ||
end | ||
end | ||
end # task | ||
|
||
end # namespace :git | ||
|
||
task 'gem:release' => 'git:create_tag' | ||
end | ||
|
||
end # module Bones::Plugins::Git | ||
|
||
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
begin | ||
require "openssl" | ||
require "net/smtp" | ||
require 'time' | ||
|
||
Net::SMTP.class_eval do | ||
private | ||
|