vclog 1.9.1 → 1.10.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 (49) hide show
  1. checksums.yaml +7 -0
  2. data/{HISTORY.rdoc → History.md} +74 -13
  3. data/License.txt +23 -0
  4. data/{README.rdoc → README.md} +46 -45
  5. data/bin/vclog-news +6 -0
  6. data/lib/vclog/adapters/abstract.rb +3 -8
  7. data/lib/vclog/adapters/git.rb +71 -133
  8. data/lib/vclog/adapters/svn.rb +1 -1
  9. data/lib/vclog/change.rb +8 -8
  10. data/lib/vclog/change_point.rb +0 -1
  11. data/lib/vclog/cli/abstract.rb +2 -2
  12. data/lib/vclog/cli/news.rb +29 -0
  13. data/lib/vclog/config.rb +149 -0
  14. data/lib/vclog/core_ext.rb +14 -101
  15. data/lib/vclog/heuristics.rb +37 -5
  16. data/lib/vclog/history_file.rb +15 -3
  17. data/lib/vclog/metadata.rb +1 -16
  18. data/lib/vclog/repo.rb +27 -55
  19. data/lib/vclog/report.rb +38 -20
  20. data/lib/vclog/tag.rb +19 -6
  21. data/lib/vclog/version.rb +3 -0
  22. data/man/man1/index.txt +1 -0
  23. data/man/man1/vclog-autotag.1.ronn +1 -1
  24. data/man/man1/vclog-bump.1.ronn +1 -1
  25. data/man/man1/vclog-news.1.ronn +25 -0
  26. data/man/man1/vclog-version.1.ronn +1 -1
  27. metadata +109 -108
  28. data/.ruby +0 -61
  29. data/COPYING.rdoc +0 -32
  30. data/features/git.feature +0 -86
  31. data/features/hg.feature +0 -86
  32. data/features/step_definitions/history_steps.rb +0 -29
  33. data/features/step_definitions/repo_steps.rb +0 -72
  34. data/features/support/ae.rb +0 -1
  35. data/features/support/aruba.rb +0 -5
  36. data/features/support/loadpath.rb +0 -2
  37. data/features/support/repo.rb +0 -19
  38. data/features/svn.feature +0 -86
  39. data/lib/vclog.yml +0 -61
  40. data/man/man1/vclog-autotag.1 +0 -29
  41. data/man/man1/vclog-autotag.1.html +0 -117
  42. data/man/man1/vclog-bump.1 +0 -23
  43. data/man/man1/vclog-bump.1.html +0 -111
  44. data/man/man1/vclog-version.1 +0 -16
  45. data/man/man1/vclog-version.1.html +0 -100
  46. data/man/man1/vclog.1 +0 -51
  47. data/man/man1/vclog.1.html +0 -131
  48. data/test/unit/case_metadata.rb +0 -11
  49. data/test/unit/helper.rb +0 -4
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9cc7a6945a99a617bd6a0374187f3f86c24f32e04f03bb328001f75c71b933da
4
+ data.tar.gz: 8033a3eb390daa38d015c1159b2d960cd76b54820a456e5b97a89585b9064d8d
5
+ SHA512:
6
+ metadata.gz: 3ef58ecb224ea05db5d2eaeb2a2a35b4f502fc25b581153cb0889bcb5562c54f0e321fc6c583551b707a3436887750e09128e2e4e95a946aed42ca907603b83c
7
+ data.tar.gz: 30a815a2a2d3c388e6bf2a0080cddbc8f91968edc2b5800f45873726f886256a5a6c7a4593e5e0125880daa4f3880d2eb5dcfa8c397227481197f738b02137af
@@ -1,6 +1,63 @@
1
- = RELEASE HISTORY
1
+ # RELEASE HISTORY
2
2
 
3
- == 1.9.1 / 2011-12-13
3
+ ## 1.10.0 / 2026-11-24
4
+
5
+ The first release since 2012. It makes VCLog work on current Ruby (2.7
6
+ to 4.0) and with current Facets, RDoc and Git, and fixes a number of
7
+ long-standing bugs. Version 1.9.3 was prepared in 2012 but never
8
+ released; its changes are included here.
9
+
10
+ Changes:
11
+
12
+ * Fix loading with Facets 4, which no longer has `String#tabto` or
13
+ `Enumerable#group_by` files. (#18)
14
+ * Fix release histories putting a tagged commit in the release after
15
+ its own. (#16)
16
+ * Fix reading of Git tags: a tag message beginning with a letter from
17
+ a to f, or a long one, could break `vclog -r`, `vclog-version` and
18
+ `vclog-bump`. (#15)
19
+ * Fix a crash on Git commits that change no files, and on commits and
20
+ tags with an empty message. (#17, thanks to Christopher Fuhrman)
21
+ * The current version is the highest version tag, so 0.10.0 comes
22
+ after 0.9.0, where before it was the last tag by name.
23
+ * `-p` (`--point`) now splits commit messages into points and the
24
+ default doesn't; the two were the wrong way round.
25
+ * `vclog-bump` gives the next patch version when nothing has changed
26
+ since the last release, where before it failed.
27
+ * Find the history file whatever its case (`History.md`, `HISTORY.md`).
28
+ * Find a project's config file (`etc/vclog.rb`, `config/vclog.rb`,
29
+ `.vclog`, ...), which the last code on master failed to do.
30
+ * Fix the HTML format with current RDoc, and ERB templates on Ruby 3.
31
+ * Fix `Heuristics.eval` and `Heuristics#level`, which raised errors.
32
+ * Error messages go to standard error.
33
+ * Git commands are run without a shell.
34
+ * Depend on `ostruct`, `json` and `rdoc`, which are no longer always
35
+ part of Ruby.
36
+ * Remove the RC configuration support that was added for 1.9.3 and
37
+ deprecated before any release.
38
+ * Tests run on Spectrum and Assay, against a Git repository built for
39
+ the purpose, and check what the commands print. Before, they needed
40
+ the network and didn't check anything.
41
+
42
+
43
+ ## 1.9.2 / 2012-03-03
44
+
45
+ Adds `vclog-news` command to output the lastest release entry in a project History file.
46
+ Also attempts to fix issue #14 in which template is not being found --will at least
47
+ report more useful error message if it happens in the future. Also, improved handling
48
+ of configuration. You can now use `.vclog`, `config/vclog` or `.config/vclog`
49
+ by defatult, or add `vclog: path/to/config/file` entry to `.map` file is you wish
50
+ to use unconventional location.
51
+
52
+ Changes:
53
+
54
+ * Add news command to get latest release history.
55
+ * Improve configuration file handling.
56
+ * Improve Report code to avoid missing templates.
57
+ * Switch to Lime for spec testing, instead of Cucumber.
58
+
59
+
60
+ ## 1.9.1 / 2011-12-13
4
61
 
5
62
  Fixes a couple of issues found with the last release.
6
63
 
@@ -10,7 +67,7 @@ Changes:
10
67
  * Fix tag id in git tag parser.
11
68
 
12
69
 
13
- == 1.9.0 / 2011-12-12
70
+ ## 1.9.0 / 2011-12-12
14
71
 
15
72
  This is a BIG release and much has changed, so be sure to read the following
16
73
  carefully if you've used VClog before.
@@ -80,7 +137,7 @@ Changes:
80
137
  * Add autotag feature to ensure release history tags exits.
81
138
 
82
139
 
83
- == 1.7.0 / 2010-06-27
140
+ ## 1.7.0 / 2010-06-27
84
141
 
85
142
  In this release the heuristics interface has changed such that the block is passed the commit message and the matchdata, instead of the previous matchdata splat. The rule can alos return either the sybolic label or a two element array of label and new message, which allows the rule to "massage" the message as needed. This release also improves the git log parser to be much more robust.
86
143
 
@@ -90,7 +147,7 @@ Changes:
90
147
  * Improve git log parser, which should handle all possible cases now.
91
148
 
92
149
 
93
- == 1.6.1 / 2010-06-23
150
+ ## 1.6.1 / 2010-06-23
94
151
 
95
152
  This release repairs the Atom feed format and adds an RSS feed format. Both formats are nearly conformant with strict validations --only a couple minor issues remain to iron out (such as embedded feed url). Ragardless, they should work fine with feed readers (which are not as strict).
96
153
 
@@ -102,7 +159,7 @@ Changes:
102
159
  * Add title to HTML Change Log format.
103
160
 
104
161
 
105
- == 1.6.0 / 2010-06-22
162
+ ## 1.6.0 / 2010-06-22
106
163
 
107
164
  Previous versions utilized a system of "commit tagging" to identify types of commits. This proved less than optimal --it was unconventional, but worse it was easy to forget to put the proper label in the message. The new version of VClog uses a customizable heuristics systems instead. Rather than be limited to a strict syntax structure, you can write matching rules in .config/vclog/rules.rb that determine the commit type, and set descriptive labels for each type. This makes it very easy to get excellent History output. Also in this release the command-line interface has changed to use subcommands. And the default output format is now an ANSI-color GNU-like format. Use `-f gnu` to get the old default format.
108
165
 
@@ -114,7 +171,7 @@ Changes:
114
171
  * Command-line interface uses subcommands
115
172
 
116
173
 
117
- == 1.5.0 / 2010-05-29
174
+ ## 1.5.0 / 2010-05-29
118
175
 
119
176
  This release adds support for Mercurial repositories and Atom newsfeed output format. The commandline inteface has change such that <code>--foramt</code>/<code>-f</code> is used to select the format instead of using the previous per-format options, e.g. use <code>-f xml</code> instead of <code>--xml</code>. This release also includes some subtantial changes under-the-hood --the first of a two part code refactoring process.
120
177
 
@@ -130,7 +187,7 @@ Changes:
130
187
  * Select format using -f option.
131
188
 
132
189
 
133
- == 1.4.0 / 2010-05-26
190
+ ## 1.4.0 / 2010-05-26
134
191
 
135
192
  This release includes some basic improvments and a few bug fixes. The primary change you might encounter is the need to use -e or --extra in order to see the detailed Changes list in the Release History. Also changed 'git-log' to 'git log', as it seems the latest versions of git does not support the many executables any longer. SVN support requires xmlsimple library. Note also that SVN support is lack luster at this time becuase it hits the server every time an 'svn log' command is issued which is done once for each tag when a history is generated (any one know a better way?).
136
193
 
@@ -148,7 +205,7 @@ Changes:
148
205
  * Change 'git-log' to 'git log'.
149
206
 
150
207
 
151
- == 1.3.0 / 2010-02-08
208
+ ## 1.3.0 / 2010-02-08
152
209
 
153
210
  For the an end-user the only significant change is the support of 'label:' notation for commit labels. I have found that I am much more apt to use them if they come first in the commit message and that some developers already use the 'label:' notation to specify 'system module' effected --a useful system of labeling.
154
211
 
@@ -168,7 +225,7 @@ Changes:
168
225
  * Corrected error for --current and --bump commands.
169
226
 
170
227
 
171
- == 1.2.0 / 2009-10-26
228
+ ## 1.2.0 / 2009-10-26
172
229
 
173
230
  Version 1.2 overhuals the internals so that History output is based on scm tags, not on a pre-existing history file. This is really the proper way to go about it and those who use it will, I think, be happily surprised at how it promotes good practices for the maintenance of History files. This overhaul led to substantial changes in the command-line interface.
174
231
 
@@ -180,7 +237,7 @@ Changes:
180
237
  * Changed command-line interface.
181
238
 
182
239
 
183
- == 1.1.0 / 2009-10-23
240
+ ## 1.1.0 / 2009-10-23
184
241
 
185
242
  This release adds yaml and json formats an improves
186
243
  the command.
@@ -197,20 +254,24 @@ Changes:
197
254
  * Use OptionParser instead of GetoptLong.
198
255
 
199
256
 
200
- == 1.0.0 / 2009-10-13
257
+ ## 1.0.0 / 2009-10-13
201
258
 
202
259
  This is the first "production" release of VCLog.
203
260
 
261
+ Changes:
262
+
204
263
  * 2 Major Enhancements
205
264
 
206
265
  * Improved command line interface.
207
266
  * Added output option to save changelog.
208
267
 
209
268
 
210
- == 0.1.0 / 2009-08-17
269
+ ## 0.1.0 / 2009-08-17
211
270
 
212
271
  This is the initial version of vclog.
213
272
 
273
+ Changes:
274
+
214
275
  * 1 Major Enhancement
215
276
 
216
277
  * Happy Birthday
data/License.txt ADDED
@@ -0,0 +1,23 @@
1
+ BSD-2-Clause License
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice,
7
+ this list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
14
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
16
+ COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
17
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
22
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+
@@ -1,41 +1,44 @@
1
- = VCLog
1
+ # VCLog
2
2
 
3
- {Website}[http://rubyworks.github.com/vclog] |
4
- {Source Code}[http://github.com/rubyworks/vclog] |
5
- {Report Issue}[http://github.com/rubyworks/vclog/issues] |
6
- {Mailing List}[http://googlegroups.com/group/rubyworks-mailinglist]
3
+ [Report Issue](https://github.com/rubyworks/vclog/issues) /
4
+ [Source Code](https://github.com/rubyworks/vclog) &nbsp; &nbsp;
5
+ [![CI](https://github.com/rubyworks/vclog/actions/workflows/ci.yml/badge.svg)](https://github.com/rubyworks/vclog/actions/workflows/ci.yml)
7
6
 
8
- {<img src="http://travis-ci.org/rubyworks/vclog.png" />}[http://travis-ci.org/rubyworks/vclog]
7
+ **VCLog is a versatile and customizable cross-VCS/SCM changelog and release history generator.**
9
8
 
9
+ ## Supported Systems
10
10
 
11
- == DESCRIPTION
11
+ VCLog is a multi-platform VCS logging tool.
12
+ It currently supports the following Version Control Systems:
12
13
 
13
- VCLog is a versatile cross-VCS/SCM changelog generator.
14
- It currently supports Git, Hg and (limited) Subversion.
14
+ * <a href="http://git-scm.com/">Git</a>
15
+ * <a href="http://mercurial.selenic.com/">Mercurial</a>
16
+ * <a href="http://subversion.apache.org/">Subversion</a>
15
17
 
18
+ Subversion support is limited however. See Limitations noted below.
19
+ Only Git is covered by the test suite at present.
16
20
 
17
- == SYNOPSIS
21
+ VCLog needs Ruby 2.7 or newer.
18
22
 
19
- === Creating Changelogs
20
23
 
21
- The default output is an ANSI colored GNU-like changelog.
22
- From a repository's root directory try:
24
+ ## Instructions
23
25
 
24
- $ vclog
26
+ ### Creating Changelogs
25
27
 
26
- The is the same as specifying 'changelog' or 'log'.
28
+ The default output is an ANSI colored GNU-like changelog.
29
+ From a repository's root directory try:
27
30
 
28
- $ vclog log
31
+ $ vclog
29
32
 
30
33
  To generate an a different format use -f:
31
34
 
32
- $ vclog -f xml
35
+ $ vclog -f xml
33
36
 
34
- === Creating Release Histories
37
+ ### Creating Release Histories
35
38
 
36
39
  To get a release history specify `-r`, `--release` or `--history` option.
37
40
 
38
- $ vclog -r
41
+ $ vclog -r
39
42
 
40
43
  Again the default format is an ANSI colored GNU-like text style.
41
44
 
@@ -44,38 +47,34 @@ message is used as the release note. If the underlying SCM doesn't
44
47
  support tag messages than the message of the first commit prior to
45
48
  the tag is used.
46
49
 
47
- See 'vclog help' for more options.
50
+ See `vclog --help` for more options.
48
51
 
49
- === Bumping Versions
52
+ ### Bumping Versions
50
53
 
51
54
  VCLog can also be used to intelligently bump versions. To see the current
52
55
  tag version:
53
56
 
54
- $ vclog-version
55
- 1.1.0
57
+ $ vclog-version
58
+ 1.1.0
56
59
 
57
60
  To see the next reasonable version based on current changes:
58
61
 
59
- $ vclog-bump
60
- 1.2.0
62
+ $ vclog-bump
63
+ 1.2.0
61
64
 
62
65
  VCLog can determine the appropriate version based on commit level. Any
63
66
  commit with a level greater than 1 will bump the major number, while any
64
67
  commit with a level of 0 or 1 will bump the minor number. All lower
65
68
  level only bump the patch level.
66
69
 
67
- === Writing Heuristics
68
-
69
- You can configure custom log heuristics for your project. VCLog uses
70
- the {confection gem}[http://rubyworks.github.com/confection] to
71
- handle configuration, and will look for a `.confile` or `Confile` in
72
- which to find a `vclog` section.
70
+ ### Writing Heuristics
73
71
 
74
- vclog do
75
- ...
76
- end
72
+ VCLog can be configured to support custom log heuristics to suite the work flow
73
+ of any project. It is recommended that configurations be placed in a project's
74
+ `etc/vclog.rb` file. But `config/vclog.rb` and simply `.vclog` or `vclog.rb`
75
+ also work.
77
76
 
78
- Within this block we can define rules via the #on method.
77
+ Within this file rules are defined via the #on method. For example,
79
78
 
80
79
  on /updated? (README|VERSION|MANIFEST)/ do |commit|
81
80
  commit.label = "Adminstrative Changes"
@@ -97,7 +96,7 @@ These rules can also "massage" the commit message.
97
96
 
98
97
  on /\Aadmin:/ do |commit, matchdata|
99
98
  commit.type = :admin
100
- commit.message = matchdate.post_match
99
+ commit.message = matchdata.post_match
101
100
  end
102
101
 
103
102
  Lastly, we can customize the colorization of the certain formats via #colors
@@ -105,8 +104,12 @@ method.
105
104
 
106
105
  colors :blue, :cyan, :green, :yellow, :red
107
106
 
107
+ The colors are taken in order from least importance to greatest importance.
108
108
 
109
- == SUBVERSION ISSUES
109
+
110
+ ## Limitations
111
+
112
+ ### Subversion
110
113
 
111
114
  Because Subversion is a centralized version control system, it contacts
112
115
  the server every time 'svn log' is run. For this reason, having vclog
@@ -116,15 +119,13 @@ access by the server for making too many rapid requests. I have no
116
119
  idea how to remedy this issue. If you have any ideas please let me know.
117
120
 
118
121
 
119
- == RELEASE NOTES
120
-
121
- Please see HISTORY file.
122
-
122
+ ## Copyrights
123
123
 
124
- == COPYRIGHTS
124
+ VCLog (https://github.com/rubyworks/vclog)
125
125
 
126
- Copyright (c) 2008 Rubyworks
126
+ Copyright &copy; 2008 Rubyworks. All rights reserved.
127
127
 
128
- VCLog is distributable in accordance with the terms of the *FreeBSD* license.
128
+ VCLog is modifiable and redistributable in accordance with the terms of
129
+ the *BSD-2-Clause* license.
129
130
 
130
- See COPYING.rdoc for details.
131
+ See License.txt for details.
data/bin/vclog-news ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'vclog/cli/news'
4
+
5
+ VCLog::CLI::News.run(ARGV)
6
+
@@ -73,15 +73,10 @@ module VCLog
73
73
  tags.find{ |t| t.name == name }
74
74
  end
75
75
 
76
- # Returns the current verion string.
76
+ # Returns the current version string: the highest version tag.
77
77
  def version
78
- if tags.last
79
- v = tags[-1].name # TODO: ensure the latest version
80
- v = tags[-2].name if v == 'HEAD'
81
- else
82
- v = '0.0.0'
83
- end
84
- return v
78
+ latest = tags.reject{ |t| t.name == 'HEAD' }.sort.first
79
+ latest ? latest.name : '0.0.0'
85
80
  end
86
81
 
87
82
  # Return the latest commit as of a given date.
@@ -8,137 +8,83 @@ module VCLog
8
8
  #
9
9
  class Git < Abstract
10
10
 
11
- GIT_COMMIT_MARKER = '=====%n'
12
- GIT_FIELD_MARKER = '-----%n'
13
-
14
- RUBY_COMMIT_MARKER = "=====\n"
15
- RUBY_FIELD_MARKER = "-----\n"
11
+ # Fields and records are separated by control characters, which
12
+ # don't turn up in commit messages or file names.
13
+ FIELD = "\x1f"
14
+ RECORD = "\x1e"
16
15
 
17
16
  # Collect changes, i.e. commits.
18
17
  def extract_changes
19
- list = []
20
-
21
- command = 'git log --name-only --pretty=format:"' +
22
- GIT_COMMIT_MARKER +
23
- '%ci' +
24
- GIT_FIELD_MARKER +
25
- '%aN' +
26
- GIT_FIELD_MARKER +
27
- '%H' +
28
- GIT_FIELD_MARKER +
29
- '%s%n%n%b' +
30
- GIT_FIELD_MARKER +
31
- '"'
32
-
33
- changes = `#{command}`.split(RUBY_COMMIT_MARKER)
34
-
35
- changes.shift # throw the first (empty) entry away
36
-
37
- changes.each do |entry|
38
- date, who, id, msg, files = entry.split(RUBY_FIELD_MARKER)
39
- date = Time.parse(date)
40
- files = files.split("\n")
41
- list << Change.new(:id=>id, :date=>date, :who=>who, :msg=>msg, :files=>files)
18
+ format = ['%ci', '%aN', '%H', '%s%n%n%b', ''].join('%x1f')
19
+ output = git('log', '--name-only', "--pretty=format:%x1e#{format}")
20
+
21
+ output.split(RECORD).reject{ |entry| entry.strip.empty? }.map do |entry|
22
+ date, who, id, msg, files = entry.split(FIELD)
23
+ Change.new(
24
+ :id => id,
25
+ :date => Time.parse(date),
26
+ :who => who,
27
+ :msg => msg.to_s.strip,
28
+ :files => files.to_s.split("\n").reject{ |f| f.empty? }
29
+ )
42
30
  end
31
+ end
43
32
 
44
- return list
45
- end
46
-
47
- #
48
- #def extract_files(change_list)
49
- # change_list.each do |change|
50
- # files = `git show --pretty="format:" --name-only #{c.id}`
51
- # files = files.split("\n")
52
- # change.files = files
53
- # end
54
- #end
55
-
56
- # Collect tags.
57
- #
58
- # `git show 1.0` produces:
59
- #
60
- # tag 1.0
61
- # Tagger: 7rans <transfire@gmail.com>
62
- # Date: Sun Oct 25 09:27:58 2009 -0400
63
- #
64
- # version 1.0
65
- # commit
66
- # ...
67
- #
68
- # @todo This code is pretty poor, but it suffices for now.
69
- # And we need not worry about it the future b/c eventually
70
- # we will replace it by using the `amp` or `scm` gem.
33
+ # Collect tags. An annotated tag has its own author, date and
34
+ # message; a lightweight tag takes them from its commit.
71
35
  def extract_tags
72
- list = []
73
- tags = `git tag -l`
74
- tags.split(/\s+/).each do |tag|
75
- next unless version_tag?(tag) # only version tags
76
- id, who, date, rev, msg = nil, nil, nil, nil, nil
77
- info = `git show #{tag}`
78
- info, *_ = info.split(/^(commit|diff|----)/)
79
- if /\Atag/ =~ info
80
- msg = ''
81
- info.lines.to_a[1..-1].each do |line|
82
- case line
83
- when /^Tagger:/
84
- who = $'.strip
85
- when /^Date:/
86
- date = $'.strip
87
- when /^\s*[a-f0-9]+/
88
- id = $0.strip
89
- else
90
- msg << line
91
- end
92
- end
93
- msg = msg.strip
94
-
95
- #info = `git show #{tag}^ --pretty=format:"%ci|~|%H|~|"`
96
- #cdate, id, *_ = *info.split('|~|')
97
-
98
- info = git_show("#{tag}")
36
+ format = %w[
37
+ %(refname:short) %(objecttype) %(objectname) %(*objectname)
38
+ %(taggername) %(taggeremail) %(taggerdate:iso8601) %(contents)
39
+ ].join('%1f') + '%1e'
99
40
 
100
- change = Change.new(info)
41
+ output = git('for-each-ref', "--format=#{format}", 'refs/tags')
101
42
 
102
- list << Tag.new(:id=>change.id, :name=>tag, :date=>date, :who=>who, :msg=>msg, :commit=>change)
103
- else
104
- #info = `git show #{tag} --pretty=format:"%cn|~|%ce|~|%ci|~|%H|~|%s|~|"`
105
- info = git_show(tag)
43
+ list = []
44
+ output.split(RECORD).each do |entry|
45
+ name, type, id, commit_id, who, email, date, msg = entry.sub(/\A\n/, '').split(FIELD)
46
+ next if name.nil? || name.empty?
47
+ next unless version_tag?(name) # only version tags
48
+
49
+ if type == 'tag'
50
+ next if commit_id.to_s.empty? # a tag of something other than a commit
51
+ change = Change.new(git_show(commit_id))
52
+ list << Tag.new(
53
+ :id => change.id,
54
+ :name => name,
55
+ :date => date,
56
+ :who => "#{who} #{email}".strip,
57
+ :msg => msg.to_s.strip,
58
+ :commit => change
59
+ )
60
+ elsif type == 'commit'
61
+ info = git_show(id)
106
62
  change = Change.new(info)
107
-
108
- tag_info = {
109
- :name => tag,
63
+ list << Tag.new(
64
+ :name => name,
110
65
  :who => info[:who],
111
66
  :date => info[:date],
112
67
  :msg => info[:message],
113
68
  :commit => change
114
- }
115
- list << Tag.new(tag_info)
116
- end
117
-
118
- #if $DEBUG
119
- # p who, date, rev, msg
120
- # puts
121
- #end
122
-
123
- #list << tag
69
+ )
70
+ end
124
71
  end
125
-
126
- return list
72
+ list
127
73
  end
128
74
 
129
75
  # User name of developer.
130
76
  def user
131
- @user ||= `git config user.name`.strip
77
+ @user ||= git('config', 'user.name').strip
132
78
  end
133
79
 
134
80
  # Email address of developer.
135
81
  def email
136
- @email ||= `git config user.email`.strip
82
+ @email ||= git('config', 'user.email').strip
137
83
  end
138
84
 
139
85
  #
140
86
  def repository
141
- @repository ||= `git config remote.origin.url`.strip
87
+ @repository ||= git('config', 'remote.origin.url').strip
142
88
  end
143
89
 
144
90
  #
@@ -148,39 +94,31 @@ module VCLog
148
94
  file = tempfile("message", message)
149
95
  date = date.strftime('%Y-%m-%d 23:59') unless String===date
150
96
 
151
- cmd = %[GIT_AUTHOR_DATE='#{date}' GIT_COMMITTER_DATE='#{date}' git tag -a -F '#{file}' #{label} #{ref}]
152
- puts cmd if $DEBUG
153
- `#{cmd}` unless $DRYRUN
97
+ env = {'GIT_AUTHOR_DATE'=>date, 'GIT_COMMITTER_DATE'=>date}
98
+ cmd = ['git', '-C', root.to_s, 'tag', '-a', '-F', file, label.to_s, ref.to_s]
99
+ puts cmd.join(' ') if $DEBUG
100
+ system(env, *cmd) unless $DRYRUN
154
101
  end
155
102
 
156
103
  private
157
104
 
158
- #
159
- #
160
- #
105
+ # Run git in the project's root and return what it prints.
106
+ def git(*args)
107
+ IO.popen(['git', '-C', root.to_s, *args], :err=>File::NULL, &:read).to_s
108
+ end
109
+
110
+ # Details of a single commit.
161
111
  def git_show(ref)
162
- command = 'git show ' + ref.to_s + ' --name-only --pretty=format:"' +
163
- '%ci' +
164
- GIT_FIELD_MARKER +
165
- '%cn' +
166
- GIT_FIELD_MARKER +
167
- '%ce' +
168
- GIT_FIELD_MARKER +
169
- '%H' +
170
- GIT_FIELD_MARKER +
171
- '%s%n%n%b' +
172
- GIT_FIELD_MARKER +
173
- '"'
174
-
175
- entry = `#{command}`
176
-
177
- date, who, email, id, msg, files = entry.split(RUBY_FIELD_MARKER)
178
-
179
- who = who + ' ' + email
180
- date = Time.parse(date)
181
- files = files.split("\n")
182
-
183
- return { :date=>date, :who=>who, :id=>id, :message=>msg, :files=>files }
112
+ format = ['%ci', '%cn', '%ce', '%H', '%s%n%n%b', ''].join('%x1f')
113
+ entry = git('show', '--name-only', "--pretty=format:#{format}", ref.to_s)
114
+
115
+ date, who, email, id, msg, files = entry.split(FIELD)
116
+
117
+ { :date => Time.parse(date),
118
+ :who => "#{who} #{email}",
119
+ :id => id,
120
+ :message => msg.to_s.strip,
121
+ :files => files.to_s.split("\n").reject{ |f| f.empty? } }
184
122
  end
185
123
 
186
124
  end
@@ -135,7 +135,7 @@ module VCLog
135
135
  file = tempfile("message", message)
136
136
 
137
137
  Dir.chdir(root) do
138
- cmd = %[svn copy -r #{ref} -F "#{mfile.path}" . #{tag_directory}/#{label}]
138
+ cmd = %[svn copy -r #{ref} -F "#{file}" . #{tag_directory}/#{label}]
139
139
  puts cmd if $DEBUG
140
140
  `#{cmd}` unless $DRYRUN
141
141
  end