Included Modules

Class Index [+]

Quicksearch

Bones::Plugins::Git

Public Instance Methods

define_tasks() click to toggle source
    # File lib/bones/plugins/git.rb, line 15
15:   def define_tasks
16:     return unless have? :git
17: 
18:     config = ::Bones.config
19:     namespace :git do
20: 
21:       # A prerequisites task that all other tasks depend upon
22:       task :prereqs
23: 
24:       desc 'Show tags from the git repository'
25:       task :tags => 'git:prereqs' do |t|
26:         puts Git.open('.').tags.map {|t| t.name}.reverse
27:       end
28: 
29:       desc 'Show all log messages since the last release'
30:       task :changes => 'git:prereqs' do |t|
31:         tag = Git.open('.').tags.map {|t| t.name}.last
32:         range = tag ? "#{tag}..HEAD" : ''
33:         system "git log --oneline #{range}"
34:       end
35: 
36:       desc 'Create a new tag in the git repository'
37:       task :create_tag => 'git:prereqs' do |t|
38:         v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
39:         abort "Versions don't match #{v} vs #{config.version}" if v != config.version
40: 
41:         git = Git.open '.'
42:         tag = "%s-%s" % [config.name, config.version]
43:         puts "Creating git tag '#{tag}'."
44: 
45:         begin
46:           git.add_tag tag
47:         rescue Git::GitExecuteError
48:           abort "Tag creation failed: tag '#{tag}' already exists."
49:         end
50: 
51:         if git.remotes.map {|r| r.name}.include? 'origin'
52:           unless system "git push origin #{tag}"
53:             abort "Could not push tag to remote git repository."
54:           end
55:         end
56:       end  # task
57: 
58:       desc 'Delete a tag from the git repository'
59:       task :delete_tag => 'git:prereqs' do |t|
60:         v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
61: 
62:         git = Git.open '.'
63:         tag = "%s-%s" % [config.name, v]
64: 
65:         unless git.tags.map {|t| t.name}.include? tag
66:           puts "Tag '#{tag}' does not exist."
67:           break
68:         end
69: 
70:         puts "Deleting git tag '#{tag}'."
71:         abort 'Tag deletion failed.' unless system "git tag -d '#{tag}'"
72: 
73:         if git.remotes.map {|r| r.name}.include? 'origin'
74:           unless system "git push origin ':refs/tags/#{tag}'"
75:             abort "Could not delete tag from remote git repository."
76:           end
77:         end
78:       end  # task
79: 
80:       task :dev_version do |t|
81:         rgxp = Regexp.new(Regexp.escape(config.version) + '-(\d+)')
82:         m = rgxp.match(%(git describe --tags))
83:         (config.version << ".#{m[1]}") if m
84:       end  # task
85: 
86:     end  # namespace :git
87: 
88:     task 'gem:package' => 'git:dev_version'
89:     task 'gem:release' => 'git:create_tag'
90:   end
post_load() click to toggle source
    # File lib/bones/plugins/git.rb, line 8
 8:   def post_load
 9:     have?(:git) {
10:       Dir.entries(Dir.pwd).include?('.git') and
11:       system("git --version 2>&1 > #{DEV_NULL}")
12:     }
13:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.