module Hoe::Git

This module is a Hoe plugin. You can set its attributes in your Rakefile Hoe spec, like this:

Hoe.plugin :git

Hoe.spec "myproj" do
  self.git_release_tag_prefix  = "REL_"
  self.git_remotes            << "myremote"
end

Tasks

git:changelog

Print the current changelog.

git:manifest

Update the manifest with Git’s file list.

git:tag

Create and push a tag.

Constants

VERSION

Duh.

Attributes

git_release_tag_prefix[RW]

What do you want at the front of your release tags?

default: "v"
git_remotes[RW]

Which remotes do you want to push tags, etc. to?

default: %w(origin)

Public Instance Methods

changelog_section(code) click to toggle source
# File lib/hoe/git.rb, line 166
def changelog_section code
  name = {
    :major   => "major enhancement",
    :minor   => "minor enhancement",
    :bug     => "bug fix",
    :unknown => "unknown",
  }[code]

  changes = $changes[code]
  count = changes.size
  name += "s" if count > 1
  name.sub!(%rfixs/, 'fixes')

  return if count < 1

  puts "* #{count} #{name}:"
  puts
  changes.sort.each do |line|
    puts "  * #{line}"
  end
  puts
end
git_svn?() click to toggle source
# File lib/hoe/git.rb, line 128
def git_svn?
  File.exist? ".git/svn"
end
git_tag_and_push(tag) click to toggle source
# File lib/hoe/git.rb, line 132
def git_tag_and_push tag
  msg = "Tagging #{tag}."

  if git_svn?
    sh "git svn tag #{tag} -m '#{msg}'"
  else
    sh "git tag -f #{tag} -m '#{msg}'"
    git_remotes.each { |remote| sh "git push -f #{remote} tag #{tag}" }
  end
end
git_tags() click to toggle source
# File lib/hoe/git.rb, line 143
def git_tags
  if git_svn?
    source = %xgit config svn-remote.svn.tags`.strip

    unless source =~ %r{refs/remotes/(.*)/\*$}
      abort "Can't discover git-svn tag scheme from #{source}"
    end

    prefix = $1

    %xgit branch -r`.split("\n").
      collect { |t| t.strip }.
      select  { |t| t =~ %r{^#{prefix}/#{git_release_tag_prefix}} }
  else
    flags  = "--date-order --simplify-by-decoration --pretty=format:%H"
    hashes = %xgit log #{flags}`.split(%r\n/).reverse
    names  = %xgit name-rev --tags #{hashes.join " "}`.split(%r\n/)
    names  = names.map { |s| s[%rtags\/(v.+)/, 1] }.compact
    names  = names.map { |s| s.sub(%r\^0$/, '') }
    names.select { |t| t =~ %r{^#{git_release_tag_prefix}} }
  end
end