hoe-git2 1.7.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.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.rdoc +92 -0
  3. data/Manifest.txt +5 -0
  4. data/README.rdoc +95 -0
  5. data/Rakefile +25 -0
  6. data/lib/hoe/git2.rb +205 -0
  7. metadata +137 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d7aac80c05332e9faf7b61b526e7d3dbce4f8e2f04e4851bf42fa25719ed07c8
4
+ data.tar.gz: 783d51ff0f977cbd7cb93150225c8e0b0bbd9615c5b48afb958590795bb77c21
5
+ SHA512:
6
+ metadata.gz: 45447bf8aa1a2a1bd4aa8d469fa04a3f9c5e3c22dde457ecb2d275ddb45459ea048a75df109b091ecd00880bded2f8daf9e401e9e427bcc81e4abb444c5aa4d3
7
+ data.tar.gz: 70c54520d3c71db1eff92c26bb6a09cf32eb448d6b3bae0bb5b538413ea0dbc4378fe42a2c3737f0f1efbd9e10ba902ecab2f7d80a221853d8b02e106a62d659
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,92 @@
1
+ === 1.7.0 / 2022-07-18
2
+
3
+ * 2 minor enhancements:
4
+
5
+ * Incorporated the porcelain change for jbarnette/hoe-git#14, resolving
6
+ jbarnette/hoe-git#13. Thanks to @ghost for the original contribution.
7
+
8
+ * Improved in-git and git-svn detection to use git porcelain instead of
9
+ strict directory detection.
10
+
11
+ * This is sort of a re-birthday! Since jbarnette/hoe-git has been archived,
12
+ I've forked the repository and released this plug-in as +hoe-git2+. I've
13
+ also chosen to reformat this to my preferred style. I have released this
14
+ using the same versioning as +hoe-git+ because this is very much a
15
+ continuation of the original code.
16
+
17
+ === 1.6.0 / 2014-02-05
18
+
19
+ * 1 minor enhancement:
20
+
21
+ * Added signed tag support to hoe-git
22
+
23
+ === 1.5.0 / 2012-03-22
24
+
25
+ * 1 minor enhancement:
26
+
27
+ * Added prerelease support. Use `rake release VERSION=1.0 PRE=rc.1` to
28
+ create a prerelease gem.
29
+
30
+ * 1 bug fix:
31
+
32
+ * The git:tag task is now a dependency of release_to instead of release to
33
+ ensure it runs before post_release tasks
34
+
35
+
36
+ === 1.4.1 / 2011-10-04
37
+
38
+ * 1 minor enhancement:
39
+
40
+ * Added git:tags.
41
+
42
+ * 2 bug fixes:
43
+
44
+ * Fixed name-rev to use --tags. Version diff?
45
+ * Newer versions of git are tacking on a "^0" to tag names for some stupid reason.
46
+
47
+ === 1.4.0 / 2011-05-16
48
+
49
+ * 2 minor enhancements:
50
+
51
+ * Exported all the other git functions so that other rake tasks can benefit.
52
+ * Updated git:changelog to support annotated commit messages.
53
+
54
+ * 1 bug fix:
55
+
56
+ * Fix shell escaping on Windows. [Gordon Thiesfeld]
57
+
58
+ === 1.3.0 / 2009-07-27
59
+
60
+ * Add a git:manifest task. [Phil Hagelb0rg]
61
+ * Clean up git:changelog a bit.
62
+ * Add the doofus Hoe plugin.
63
+ * Update README w/better docs.
64
+
65
+ === 1.2.0 / 2009-07-01
66
+
67
+ * Add git-svn support for git:tag and git:changelog.
68
+
69
+ === 1.1.3 / 2009-06-27
70
+
71
+ * Changelog should use author, not committer.
72
+
73
+ === 1.1.2 / 2009-06-26
74
+
75
+ * Doc cleanups.
76
+ * Veto releases when the index is dirty.
77
+
78
+ === 1.1.1 / 2009-06-23
79
+
80
+ * Use git_release_tag_prefix more consistently, handle unreleased case.
81
+ * Make the README a bit better.
82
+
83
+ === 1.1.0 / 2009-06-23
84
+
85
+ * Allow configurable release tag prefixes.
86
+ * Add git:changelog to make release notes easier.
87
+ * Make the git:tag task respect a TAG env var.
88
+ * Minor cleanups.
89
+
90
+ === 1.0.0 / 2009-06-23
91
+
92
+ * Birthday!
data/Manifest.txt ADDED
@@ -0,0 +1,5 @@
1
+ CHANGELOG.rdoc
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ lib/hoe/git2.rb
data/README.rdoc ADDED
@@ -0,0 +1,95 @@
1
+ = Hoe Loves Git
2
+
3
+ * home :: http://github.com/halostatue/hoe-git
4
+ * docs :: http://docs.seattlerb.org/hoe-git
5
+
6
+ == Description
7
+
8
+ A set of Hoe plugins for tighter Git integration. Provides tasks to automate release tagging and pushing and changelog
9
+ generation. I expect it'll learn a few more tricks in the future.
10
+
11
+ This is an evolution of +hoe-git+ by John Barnette, which has been archived at <http://github.com/jbarnette/hoe-git>.
12
+
13
+ == Examples
14
+
15
+ # in your Rakefile
16
+ Hoe.plugin :git2
17
+
18
+ If this plugin cannot see that it is in a `.git` directory, it'll silently deactivate itself.
19
+
20
+ === Autogenerating the Changelog
21
+
22
+ $ rake git:changelog
23
+
24
+ This takes all the commit messages since your last release and formats
25
+ 'em into a nice RDoc fragment. If you specify <tt>VERSION</tt>, it'll
26
+ be used in the changelog fragment. If you specify <tt>FROM</tt>, it'll
27
+ be used as a starting point for the changelog instead of your last
28
+ tagged release.
29
+
30
+ The rdoc is automatically formatted into sections by using "annotated
31
+ commit messages" by using a simple format for multi-line commit messages:
32
+
33
+ ! major change description.
34
+ + minor change description.
35
+ - bug fix description.
36
+ un-logged description (for minor stuff like re-formatting).
37
+
38
+ === Generating the Manifest
39
+
40
+ $ rake git:manifest
41
+
42
+ This will regenerate <tt>Manifest.txt</tt> using <tt>git
43
+ ls-files</tt>. It respects Hoe's manifest sort order and excludes.
44
+
45
+ === Tagging and Sanity Checking a Release
46
+
47
+ $ rake release VERSION=1.0.0
48
+
49
+ In addition to the normal RubyForge release process, this will create
50
+ and push a <tt>v1.0.0</tt> tag. It'll also abort the release if your
51
+ index is dirty, or if there are untracked files present.
52
+
53
+ === git-svn
54
+
55
+ The <tt>git:changelog</tt> and <tt>git:tag</tt> tasks understand
56
+ <tt>git-svn</tt> repositories, and will adjust their behavior
57
+ accordingly.
58
+
59
+ == Dependencies
60
+
61
+ Hoe and Git, obviously. I wouldn't be surprised if things don't quite
62
+ work for git < 2.37.
63
+
64
+ == Installation
65
+
66
+ $ gem install hoe-git2
67
+
68
+ == TODO
69
+
70
+ * Release tags are sorted lexicographically right now, which won't
71
+ work for long.
72
+
73
+ == License
74
+
75
+ Copyright 2009 John Barnette (jbarnette@rubyforge.org)
76
+ Copyright 2022 Austin Ziegler (halostatue@gmail.com)
77
+
78
+ Permission is hereby granted, free of charge, to any person obtaining
79
+ a copy of this software and associated documentation files (the
80
+ 'Software'), to deal in the Software without restriction, including
81
+ without limitation the rights to use, copy, modify, merge, publish,
82
+ distribute, sublicense, and/or sell copies of the Software, and to
83
+ permit persons to whom the Software is furnished to do so, subject to
84
+ the following conditions:
85
+
86
+ The above copyright notice and this permission notice shall be
87
+ included in all copies or substantial portions of the Software.
88
+
89
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
90
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
91
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
92
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
93
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
94
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
95
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift "lib"
4
+
5
+ require "rubygems"
6
+ require "hoe"
7
+
8
+ Hoe.plugin :doofus
9
+ Hoe.plugin :gemspec2
10
+ Hoe.plugin :git2
11
+
12
+ Hoe.spec "hoe-git2" do
13
+ developer "John Barnette", "jbarnette@rubyforge.org"
14
+ developer "Austin Ziegler", "halostatue@gmail.com"
15
+
16
+ self.extra_rdoc_files = FileList["*.rdoc"]
17
+ self.history_file = "CHANGELOG.rdoc"
18
+ self.readme_file = "README.rdoc"
19
+
20
+ license "MIT"
21
+
22
+ extra_dev_deps << ["hoe-doofus", "~> 1.0"]
23
+ extra_dev_deps << ["hoe-gemspec2", "~> 1.1"]
24
+ extra_dev_deps << ["standard", "~> 1.0"]
25
+ end
data/lib/hoe/git2.rb ADDED
@@ -0,0 +1,205 @@
1
+ require "shellwords"
2
+
3
+ class Hoe # :nodoc:
4
+ # This module is a Hoe plugin. You can set its attributes in your
5
+ # Rakefile Hoe spec, like this:
6
+ #
7
+ # Hoe.plugin :git
8
+ #
9
+ # Hoe.spec "myproj" do
10
+ # self.git_release_tag_prefix = "REL_"
11
+ # self.git_remotes << "myremote"
12
+ # end
13
+ #
14
+ #
15
+ # === Tasks
16
+ #
17
+ # git:changelog:: Print the current changelog.
18
+ # git:manifest:: Update the manifest with Git's file list.
19
+ # git:tag:: Create and push a tag.
20
+
21
+ module Git2
22
+ # Duh.
23
+ VERSION = "1.7.0"
24
+
25
+ # What do you want at the front of your release tags?
26
+ # [default: <tt>"v"</tt>]
27
+
28
+ attr_accessor :git_release_tag_prefix
29
+
30
+ # Which remotes do you want to push tags, etc. to?
31
+ # [default: <tt>%w(origin)</tt>]
32
+
33
+ attr_accessor :git_remotes
34
+
35
+ def initialize_git2 # :nodoc:
36
+ self.git_release_tag_prefix = "v"
37
+ self.git_remotes = %w[origin]
38
+ end
39
+
40
+ def define_git2_tasks # :nodoc:
41
+ return unless __run_git("rev-parse", "--is-inside-work-tree") == "true"
42
+
43
+ desc "Print the current changelog."
44
+ task "git:changelog" do
45
+ tag = ENV["FROM"] || git_tags.last
46
+ range = [tag, "HEAD"].compact.join("..")
47
+ now = Time.new.strftime("%Y-%m-%d")
48
+
49
+ changes =
50
+ __run_git("log", range, "--format=tformat:%B|||%aN|||%aE|||")
51
+ .split("|||")
52
+ .each_slice(3)
53
+ .map do |msg, _author, _email|
54
+ msg.split("\n").reject(&:empty?)
55
+ end
56
+
57
+ changes = changes.flatten
58
+
59
+ next if changes.empty?
60
+
61
+ $changes = Hash.new { |h, k| h[k] = [] } # standard:disable Style/GlobalVars
62
+
63
+ codes = {
64
+ "!" => :major,
65
+ "+" => :minor,
66
+ "*" => :minor,
67
+ "-" => :bug,
68
+ "?" => :unknown
69
+ }
70
+
71
+ codes_re = Regexp.escape codes.keys.join
72
+
73
+ changes.each do |change|
74
+ if change =~ /^\s*([#{codes_re}])\s*(.*)/
75
+ code, line = codes[$1], $2
76
+ else
77
+ code, line = codes["?"], change.chomp
78
+ end
79
+
80
+ $changes[code] << line # standard:disable Style/GlobalVars
81
+ end
82
+
83
+ puts "=== #{ENV["VERSION"] || "NEXT"} / #{now}"
84
+ puts
85
+ changelog_section :major
86
+ changelog_section :minor
87
+ changelog_section :bug
88
+ changelog_section :unknown
89
+ puts
90
+ end
91
+
92
+ desc "Update the manifest with Git's file list. Use Hoe's excludes."
93
+ task "git:manifest" do
94
+ with_config do |config, _|
95
+ files = __run_git("ls-files").split($/)
96
+ files.reject! { |f| f =~ config["exclude"] }
97
+
98
+ File.open "Manifest.txt", "w" do |f|
99
+ f.puts files.sort.join("\n")
100
+ end
101
+ end
102
+ end
103
+
104
+ desc "Create and push a TAG (default #{git_release_tag_prefix}#{version})."
105
+ task "git:tag" do
106
+ tag = ENV["TAG"]
107
+ ver = ENV["VERSION"] || version
108
+ pre = ENV["PRERELEASE"] || ENV["PRE"]
109
+ ver += ".#{pre}" if pre
110
+ tag ||= "#{git_release_tag_prefix}#{ver}"
111
+
112
+ git_tag_and_push tag
113
+ end
114
+
115
+ task "git:tags" do
116
+ p git_tags
117
+ end
118
+
119
+ task :release_sanity do
120
+ unless __run_git("status", "--porcelain").empty?
121
+ abort "Won't release: Dirty index or untracked files present!"
122
+ end
123
+ end
124
+
125
+ task release_to: "git:tag"
126
+ end
127
+
128
+ def __git(command, *params)
129
+ "git #{command.shellescape} #{params.compact.shelljoin}"
130
+ end
131
+
132
+ def __run_git(command, *params)
133
+ `#{__git(command, *params)}`.strip.chomp
134
+ end
135
+
136
+ def git_svn?
137
+ File.exist?(File.join(__run_git("rev-parse", "--show-toplevel"), ".git/svn"))
138
+ end
139
+
140
+ def git_tag_and_push tag
141
+ msg = "Tagging #{tag}."
142
+
143
+ if git_svn?
144
+ sh __git("svn", "tag", tag, "-m", msg)
145
+ else
146
+ flags =
147
+ if __run_git("config", "--get", "user.signingkey").empty?
148
+ nil
149
+ else
150
+ "-s"
151
+ end
152
+
153
+ sh __git("tag", flags, "-f", tag, "-m", msg)
154
+ git_remotes.each { |remote| sh __git("push", "-f", remote, "tag", tag) }
155
+ end
156
+ end
157
+
158
+ def git_tags
159
+ if git_svn?
160
+ source = __run_git("config", "svn-remote.svn.tags")
161
+
162
+ unless source =~ %r{refs/remotes/(.*)/\*$}
163
+ abort "Can't discover git-svn tag scheme from #{source}"
164
+ end
165
+
166
+ prefix = $1
167
+
168
+ __run_git("branch", "-r")
169
+ .split($/)
170
+ .collect { |t| t.strip }
171
+ .select { |t| t =~ %r{^#{prefix}/#{git_release_tag_prefix}} }
172
+ else
173
+ flags = %w[--date-order --simplify-by-decoration --pretty=format:%H]
174
+ hashes = __run_git("log", *flags).split($/).reverse
175
+ names = __run_git("name-rev", "--tags", *hashes).split($/)
176
+ names = names.map { |s| s[/tags\/(v.+)/, 1] }.compact
177
+ names = names.map { |s| s.sub(/\^0$/, "") }
178
+ names.select { |t| t =~ %r{^#{git_release_tag_prefix}} }
179
+ end
180
+ end
181
+
182
+ def changelog_section(code)
183
+ name = {
184
+ major: "major enhancement",
185
+ minor: "minor enhancement",
186
+ bug: "bug fix",
187
+ unknown: "unknown"
188
+ }[code]
189
+
190
+ changes = $changes[code] # standard:disable Style/GlobalVars
191
+ count = changes.size
192
+ name += "s" if count > 1
193
+ name.sub!(/fixs/, "fixes")
194
+
195
+ return if count < 1
196
+
197
+ puts "* #{count} #{name}:"
198
+ puts
199
+ changes.sort.each do |line|
200
+ puts " * #{line}"
201
+ end
202
+ puts
203
+ end
204
+ end
205
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hoe-git2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.7.0
5
+ platform: ruby
6
+ authors:
7
+ - John Barnette
8
+ - Austin Ziegler
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2022-07-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hoe-doofus
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: hoe-gemspec2
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.1'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.1'
42
+ - !ruby/object:Gem::Dependency
43
+ name: standard
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rdoc
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '4.0'
63
+ - - "<"
64
+ - !ruby/object:Gem::Version
65
+ version: '7'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '4.0'
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: '7'
76
+ - !ruby/object:Gem::Dependency
77
+ name: hoe
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.24'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.24'
90
+ description: |-
91
+ A set of Hoe plugins for tighter Git integration. Provides tasks to automate release tagging and pushing and changelog
92
+ generation. I expect it'll learn a few more tricks in the future.
93
+
94
+ This is an evolution of +hoe-git+ by John Barnette, which has been archived at <http://github.com/jbarnette/hoe-git>.
95
+ email:
96
+ - jbarnette@rubyforge.org
97
+ - halostatue@gmail.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files:
101
+ - CHANGELOG.rdoc
102
+ - Manifest.txt
103
+ - README.rdoc
104
+ files:
105
+ - CHANGELOG.rdoc
106
+ - Manifest.txt
107
+ - README.rdoc
108
+ - Rakefile
109
+ - lib/hoe/git2.rb
110
+ homepage: http://github.com/halostatue/hoe-git
111
+ licenses:
112
+ - MIT
113
+ metadata:
114
+ homepage_uri: http://github.com/halostatue/hoe-git
115
+ documentation_uri: http://docs.seattlerb.org/hoe-git
116
+ post_install_message:
117
+ rdoc_options:
118
+ - "--main"
119
+ - README.rdoc
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubygems_version: 3.3.7
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: A set of Hoe plugins for tighter Git integration
137
+ test_files: []