hoe-git 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +7 -1
- data/lib/hoe/git.rb +49 -11
- metadata +1 -1
data/CHANGELOG.rdoc
CHANGED
data/lib/hoe/git.rb
CHANGED
@@ -1,30 +1,68 @@
|
|
1
1
|
# Tasks provided:
|
2
2
|
#
|
3
|
-
# * <tt>git:tag</
|
4
|
-
# the <tt>git_remotes</tt>. This task is added as a dependency
|
5
|
-
# the built-in <tt>release</tt> task.
|
3
|
+
# * <tt>git:tag</tt> -- Tag the current version and push the tag to
|
4
|
+
# all the <tt>git_remotes</tt>. This task is added as a dependency
|
5
|
+
# of the built-in <tt>release</tt> task. The tag will be
|
6
|
+
# <tt>"v#{version}"</tt> unless <tt>TAG</tt> or <tt>VERSION</tt> are
|
7
|
+
# set in the environment.
|
8
|
+
#
|
9
|
+
# * <tt>git:changelog</tt> -- Format a changelog of all the commits
|
10
|
+
# since the last release, or since the <tt>FROM</tt> env var if it's
|
11
|
+
# provided. Commits that weren't made by a project developer are
|
12
|
+
# attributed.
|
6
13
|
|
7
14
|
module Hoe::Git
|
8
|
-
VERSION = "1.
|
15
|
+
VERSION = "1.1.0"
|
16
|
+
|
17
|
+
##
|
18
|
+
# Optional: What do you want at the front of your release tags?
|
19
|
+
# [default: "v"]
|
20
|
+
|
21
|
+
attr_accessor :git_release_tag_prefix
|
9
22
|
|
10
23
|
##
|
11
|
-
# Optional: Which remotes do you want to push tags, etc to?
|
24
|
+
# Optional: Which remotes do you want to push tags, etc. to?
|
12
25
|
# [default: %w(origin)]
|
13
26
|
|
14
27
|
attr_accessor :git_remotes
|
15
28
|
|
16
29
|
def initialize_git
|
17
|
-
self.
|
30
|
+
self.git_release_tag_prefix = "v"
|
31
|
+
self.git_remotes = %w(origin)
|
18
32
|
end
|
19
33
|
|
20
34
|
def define_git_tasks
|
21
|
-
desc "
|
35
|
+
desc "Print the current changelog."
|
36
|
+
task "git:changelog" do
|
37
|
+
tags = `git tag -l 'v*'`.split "\n"
|
38
|
+
tag = ENV["FROM"] || tags.last
|
39
|
+
cmd = "git log #{tag}.. '--format=tformat:%s|||%cN|||%cE'"
|
40
|
+
|
41
|
+
changes = `#{cmd}`.split("\n").map do |line|
|
42
|
+
msg, author, email = line.split("|||").map { |e| e.empty? ? nil : e }
|
43
|
+
|
44
|
+
developer = author.include?(author) || email.include?(email)
|
45
|
+
change = [msg]
|
46
|
+
change << "[#{author || email}]" unless developer
|
47
|
+
|
48
|
+
change.join " "
|
49
|
+
end
|
50
|
+
|
51
|
+
puts "=== #{ENV["VERSION"] || 'NEXT'} / #{Time.new.strftime '%Y-%m-%d'}"
|
52
|
+
puts
|
53
|
+
|
54
|
+
changes.each do |change|
|
55
|
+
puts "* #{change}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Create and push a TAG (default v#{version})."
|
22
60
|
task "git:tag" do
|
23
|
-
|
24
|
-
|
61
|
+
tag = ENV["TAG"]
|
62
|
+
tag ||= "#{git_release_tag_prefix}#{ENV["VERSION"] || version}"
|
25
63
|
|
26
|
-
sh "git tag -f #{
|
27
|
-
git_remotes.each { |
|
64
|
+
sh "git tag -f #{tag}"
|
65
|
+
git_remotes.each { |remote| sh "git push -f #{remote} tag #{tag}" }
|
28
66
|
end
|
29
67
|
|
30
68
|
task :release => "git:tag"
|