vclog 1.0.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md ADDED
@@ -0,0 +1,35 @@
1
+ # RELEASE HISTORY
2
+
3
+ ## 1.1 / 2009-10-23
4
+
5
+ This release adds yaml and json formats an improves
6
+ the command.
7
+
8
+ * 2 Major Enhancements
9
+
10
+ * Added YAML format.
11
+ * Added JSON format.
12
+
13
+ * 1 Minor Enhancements
14
+
15
+ * Use OptionParser instead of GetoptLong.
16
+
17
+
18
+ ## 1.0.0 / 2009-10-13
19
+
20
+ This is the first "production" release of VCLog.
21
+
22
+ * 2 Major Enhancements
23
+
24
+ * Improved command line interface.
25
+ * Added output option to save changelog.
26
+
27
+
28
+ ## 0.1.0 / 2009-08-17
29
+
30
+ This is the initial version of vclog.
31
+
32
+ * 1 Major Enhancement
33
+
34
+ * Happy Birthday
35
+
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2009 Thomas Sawyer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+
data/MANIFEST CHANGED
@@ -1,32 +1,32 @@
1
- test
2
- RELEASE
1
+ HISTORY.md
2
+ LICENSE
3
+ MANIFEST
3
4
  README
4
- HISTORY
5
- meta
6
- meta/created
7
- meta/repository
8
- meta/homepage
9
- meta/summary
10
- meta/package
11
- meta/title
12
- meta/version
13
- meta/license
14
- meta/sitemap
15
- meta/mailinglist
16
- meta/authors
17
- meta/requires
18
- meta/project
19
- meta/description
20
- lib
5
+ TODO
6
+ bin/vclog
21
7
  lib/vclog
22
8
  lib/vclog/changelog.rb
23
- lib/vclog/core_ext.rb
9
+ lib/vclog/command.rb
10
+ lib/vclog/facets.rb
24
11
  lib/vclog/vcs
12
+ lib/vclog/vcs.rb
25
13
  lib/vclog/vcs/darcs.rb
26
14
  lib/vclog/vcs/git.rb
27
- lib/vclog/vcs/svn.rb
28
15
  lib/vclog/vcs/hg.rb
29
- lib/vclog/vcs.rb
30
- bin
31
- bin/vclog
32
- COPYING
16
+ lib/vclog/vcs/svn.rb
17
+ meta/authors
18
+ meta/contact
19
+ meta/created
20
+ meta/description
21
+ meta/homepage
22
+ meta/license
23
+ meta/loadpath
24
+ meta/parent
25
+ meta/project
26
+ meta/repository
27
+ meta/requires
28
+ meta/ruby
29
+ meta/sitemap
30
+ meta/summary
31
+ meta/title
32
+ meta/version
data/README CHANGED
@@ -6,13 +6,14 @@
6
6
 
7
7
  == DESCRIPTION
8
8
 
9
- VClog is an cross-VCS/SCM changelog generator.
9
+ VCLog is a versitle cross-VCS/SCM changelog generator.
10
+ It currently supports Git and Subversion.
10
11
 
11
12
 
12
13
  == SYNOPSIS
13
14
 
14
- VCLog generates changelogs. It supports a few different formats. The default
15
- format is standard GNU text style. From a repository's root directory try:
15
+ By default the format is a standard GNU text style. From a
16
+ repository's root directory try:
16
17
 
17
18
  $ vclog
18
19
 
@@ -25,14 +26,20 @@ See 'vclog --help' for more options.
25
26
 
26
27
  == RELEASE NOTES
27
28
 
28
- Please see RELEASE file.
29
+ Please see HISTORY file.
29
30
 
30
31
 
31
- == LICENSE & COPYRIGHT
32
+ == COPYRIGHTS
32
33
 
33
- VCLog
34
+ Copyright (c) 2009 Thomas Sawyer
34
35
 
35
- Copyright (c) 2008,2009 TigerOps.org
36
+ MIT License. See LICENSE or COPYING file for more details.
36
37
 
37
- VCLog is distributed under the terms of the GPLv3 license.
38
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
41
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44
+ THE SOFTWARE.
38
45
 
data/TODO ADDED
@@ -0,0 +1,32 @@
1
+ = TODO
2
+
3
+ == Typed option needs work
4
+
5
+ It produced no results sometimes. Fix or deprecate.
6
+
7
+
8
+ == Automagical Version
9
+
10
+ Would be cool if it could also generate an automagical version number.
11
+
12
+ === For Git
13
+
14
+ We started off by looking at what git can tell us about the current release:
15
+
16
+ * git-rev-parse <id> tells up what the ID of the <id> is, we can find out the current commit's ID by using HEAD (or nothing at all)
17
+ * git-rev-list <id>..HEAD tells us what the commits were between the <id> and the current commit
18
+ * git-describe <id> shows us, in a nice format, a unique description of the commit.
19
+
20
+ Using all of this together Patrick came up with:
21
+
22
+ BRANCH=`git-describe | awk -F'-g[0-9a-fA-F]+' '{print $1}'`
23
+ COMMIT=`git-rev-parse HEAD | awk '{print substr($1,0,8)}'`
24
+ INCREMENT=`git-rev-list $BRANCH..HEAD | wc -l | awk '{print $1}'`
25
+ TGZ="openswan-$BRANCH-($INCREMENT)-g$COMMIT.tgz"
26
+
27
+ What this attempts to achieve is create a tar ball name that describes the release using the last tag, the number of builds since the tag was made, and the short commit ID. Here is the breakdown of the bits:
28
+
29
+ * BRANCH will tell us what major release this is a part of,
30
+ * INCREMENT is a pseudo build number (it's really the number of commits since the last release), and
31
+ * g*COMMIT* is the short ID of the commit that generated the build.
32
+
data/bin/vclog CHANGED
@@ -1,131 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
+ load 'vclog/command'
3
+ VCLog.run
2
4
 
3
- # vclog
4
- #
5
- # SYNOPSIS
6
- #
7
- # VCLog provides cross-vcs ChangeLogs. It works by
8
- # parsing the native changelog a VCS system produces
9
- # into a common model, which then can be used to
10
- # produce Changelogs in a variety of formats.
11
- #
12
- # VCLog currently support SVN and Git. CVS, Darcs and
13
- # Mercurial/Hg are in the works.
14
- #
15
- # EXAMPLES
16
- #
17
- # To produce a GNU-like changelog:
18
- #
19
- # $ vclog
20
- #
21
- # For XML format:
22
- #
23
- # $ vclog --xml
24
- #
25
- # Or for a micorformat-ish HTML:
26
- #
27
- # $ vclog --html
28
- #
29
- #To use the library programmatically, please see the API documentation.
30
- #
31
- # LICENSE
32
- #
33
- # VCLog Copyright (c) 2008 Tiger Ops
34
- # VCLog is distributed under the terms of the GPLv3.
35
-
36
- require 'vclog/vcs'
37
- require 'getoptlong'
38
-
39
- # TODO: rev option.
40
- #
41
- def vclog
42
-
43
- opts = GetoptLong.new(
44
- [ '--help' , '-h', GetoptLong::NO_ARGUMENT ],
45
- [ '--debug', GetoptLong::NO_ARGUMENT ],
46
- [ '--typed', GetoptLong::NO_ARGUMENT ],
47
- [ '--rev' , GetoptLong::NO_ARGUMENT ],
48
- [ '--gnu' , GetoptLong::NO_ARGUMENT ],
49
- [ '--xml' , GetoptLong::NO_ARGUMENT ],
50
- [ '--html' , GetoptLong::NO_ARGUMENT ],
51
- [ '--rel' , GetoptLong::REQUIRED_ARGUMENT ],
52
- [ '--style', GetoptLong::REQUIRED_ARGUMENT ],
53
- [ '--output', '-o', GetoptLong::REQUIRED_ARGUMENT ]
54
- )
55
-
56
- format = :gnu
57
- typed = false
58
- rev = false
59
- vers = nil
60
- style = nil
61
- output = nil
62
-
63
- opts.each do |opt, arg|
64
- case opt
65
- when '--help'
66
- puts "vclog [--gnu|--html|--xml|--rel] [--typed]"
67
- exit
68
- when '--debug'
69
- $DEBUG = true
70
- when '--typed'
71
- typed = true
72
- when '--rev'
73
- rev = true
74
- when '--xml'
75
- format = :xml
76
- when '--html'
77
- format = :html
78
- when '--rel'
79
- format = :rel
80
- vers = arg
81
- when '--style'
82
- style = arg
83
- when '--output'
84
- output = arg
85
- end
86
- end
87
-
88
- vcs = VCLog::VCS.new
89
-
90
- changelog = vcs.changelog
91
-
92
- if typed
93
- changelog = changelog.typed
94
- end
95
-
96
- case format
97
- when :xml
98
- log = changelog.format_xml(style) # xsl stylesheet url
99
- when :html
100
- log = changelog.format_html(style) # css stylesheet url
101
- when :rel
102
- if output && File.file?(output)
103
- file = output
104
- else
105
- file = Dir.glob('change{s,log}{,.txt}', File::FNM_CASEFOLD).first
106
- end
107
- log = changelog.format_rel(file, vers)
108
- else #:gnu
109
- log = changelog.to_s
110
- end
111
-
112
- if output
113
- File.open(output, 'w') do |f|
114
- f << log
115
- end
116
- else
117
- puts log
118
- end
119
-
120
- end
121
-
122
- begin
123
- vclog
124
- rescue => err
125
- if $DEBUG
126
- raise err
127
- else
128
- puts err.message
129
- exit -1
130
- end
131
- end
@@ -1,6 +1,6 @@
1
1
  module VCLog
2
2
 
3
- require 'vclog/core_ext'
3
+ require 'vclog/facets'
4
4
 
5
5
  # Supports output formats:
6
6
  #
@@ -11,6 +11,7 @@ module VCLog
11
11
  # text
12
12
  #
13
13
  class Changelog
14
+
14
15
  include Enumerable
15
16
 
16
17
  DAY = 24*60*60
@@ -200,7 +201,7 @@ module VCLog
200
201
  end
201
202
 
202
203
  #
203
- def format_rel(file, current_version=nil, current_release=nil)
204
+ def format_rel(file, current_version=nil, current_release=nil, rev=false)
204
205
  log = []
205
206
  # collect releases already listed in changelog file
206
207
  rels = releases(file)
@@ -246,7 +247,7 @@ module VCLog
246
247
  #lt_date = Time.parse(lt_date) unless Time===lt_date
247
248
  changes = before(lt_date)
248
249
  end
249
- reltext = changes.format_rel_types
250
+ reltext = changes.format_rel_types(rev)
250
251
  unless reltext.strip.empty?
251
252
  log << "== #{lt_vers} / #{lt_date.strftime('%Y-%m-%d')}\n\n#{reltext}"
252
253
  end
@@ -256,7 +257,7 @@ module VCLog
256
257
  end
257
258
 
258
259
  #
259
- def format_rel_types
260
+ def format_rel_types(rev=false)
260
261
  groups = changes.group_by{ |e| e.type_number }
261
262
  string = ""
262
263
  5.times do |n|
@@ -267,7 +268,11 @@ module VCLog
267
268
  entries.sort!{|a,b| a.date <=> b.date }
268
269
  entries.each do |entry|
269
270
  #string << "== #{date} #{who}\n\n" # no email :(
270
- text = "#{entry.message} (##{entry.revison})"
271
+ if rev
272
+ text = "#{entry.message} (##{entry.revison})"
273
+ else
274
+ text = "#{entry.message}"
275
+ end
271
276
  text = text.tabto(6)
272
277
  text[4] = '*'
273
278
  #entry = entry.join(' ').tabto(6)
@@ -358,7 +363,7 @@ module VCLog
358
363
  end
359
364
  end
360
365
 
361
- #
366
+ # Looks for a "[type]" indicator at the end of the message.
362
367
  def split_note(note)
363
368
  note = note.strip
364
369
  if md = /\A.*?\[(.*?)\]\s*$/.match(note)
@@ -381,7 +386,7 @@ module VCLog
381
386
  attr_accessor :type
382
387
 
383
388
  def initialize(opts={})
384
- @author = opts[:author] || opts[:who]
389
+ @author = (opts[:author] || opts[:who]).strip
385
390
  @date = opts[:date] || opts[:when]
386
391
  @revison = opts[:revison] || opts[:rev]
387
392
  @message = opts[:message] || opts[:msg]
@@ -409,7 +414,9 @@ module VCLog
409
414
  when 'bug'
410
415
  'Bug Fixes'
411
416
  when ''
412
- 'Further Enhancements'
417
+ 'General Enhancements'
418
+ when '-'
419
+ 'Administrative Changes'
413
420
  else
414
421
  "#{type.capitalize} Enhancements"
415
422
  end
@@ -426,6 +433,8 @@ module VCLog
426
433
  2
427
434
  when ''
428
435
  4
436
+ when '-'
437
+ 5
429
438
  else # other
430
439
  3
431
440
  end
@@ -440,6 +449,23 @@ module VCLog
440
449
  "#<Entry:#{object_id} #{date}>"
441
450
  end
442
451
 
452
+ def to_h
453
+ { 'author' => @author,
454
+ 'date' => @date,
455
+ 'revision' => @revison,
456
+ 'message' => @message,
457
+ 'type' => @type
458
+ }
459
+ end
460
+
461
+ def to_json
462
+ to_h.to_json
463
+ end
464
+
465
+ def to_yaml(*args)
466
+ to_h.to_yaml(*args)
467
+ end
468
+
443
469
  end #class Entry
444
470
 
445
471
  end
@@ -0,0 +1,168 @@
1
+ module VCLog
2
+
3
+ require 'vclog/vcs'
4
+ require 'optparse'
5
+
6
+ # = vclog Command
7
+ #
8
+ # == SYNOPSIS
9
+ #
10
+ # VCLog provides cross-vcs ChangeLogs. It works by
11
+ # parsing the native changelog a VCS system produces
12
+ # into a common model, which then can be used to
13
+ # produce Changelogs in a variety of formats.
14
+ #
15
+ # VCLog currently support SVN and Git. CVS, Darcs and
16
+ # Mercurial/Hg are in the works.
17
+ #
18
+ # == EXAMPLES
19
+ #
20
+ # To produce a GNU-like changelog:
21
+ #
22
+ # $ vclog
23
+ #
24
+ # For XML format:
25
+ #
26
+ # $ vclog --xml
27
+ #
28
+ # Or for a micorformat-ish HTML:
29
+ #
30
+ # $ vclog --html
31
+ #
32
+ # To use the library programmatically, please see the API documentation.
33
+
34
+ def self.run
35
+ begin
36
+ vclog
37
+ rescue => err
38
+ if $DEBUG
39
+ raise err
40
+ else
41
+ puts err.message
42
+ exit -1
43
+ end
44
+ end
45
+ end
46
+
47
+ #
48
+ def self.vclog
49
+ format = :gnu
50
+ typed = false
51
+ rev = false
52
+ vers = nil
53
+ style = nil
54
+ output = nil
55
+
56
+ optparse = OptionParser.new do |opt|
57
+ opt.separator("FORMAT (choose one):")
58
+
59
+ opt.on('--gnu', "GNU standard format") do
60
+ format = :gnu
61
+ end
62
+
63
+ opt.on('--xml [XSL]', "XML format") do |file|
64
+ format = :xml
65
+ style = file
66
+ end
67
+
68
+ opt.on('--yaml', "YAML format") do
69
+ format = :yaml
70
+ end
71
+
72
+ opt.on('--json', "JSON format") do
73
+ format = :json
74
+ end
75
+
76
+ opt.on('--html [CSS]', "HTML micro-like format") do |file|
77
+ format = :html
78
+ style = file
79
+ end
80
+
81
+ opt.on('--rel <VER>', "release format") do |version|
82
+ format = :rel
83
+ vers = version
84
+ end
85
+
86
+ opt.on('--rev <VER>', "release format w/ revison ids") do |version|
87
+ format = :rev
88
+ vers = version
89
+ end
90
+
91
+ opt.separator("OTHER OPTIONS:")
92
+
93
+ opt.on('--typed', "catagorize by commit type") do
94
+ typed = true
95
+ end
96
+
97
+ #opt.on('--style [FILE]', "provide a stylesheet (css or xsl)") do |val|
98
+ # style = val
99
+ #end
100
+
101
+ opt.on('--output', '-o [FILE]', "send output to a file instead of stdout") do |out|
102
+ output = out
103
+ end
104
+
105
+ opt.separator("STANDARD OPTIONS:")
106
+
107
+ opt.on('--debug', "show debugging infromation") do
108
+ $DEBUG = true
109
+ end
110
+
111
+ opt.on_tail('--help' , '-h', 'display this help information') do
112
+ puts opt
113
+ exit
114
+ end
115
+ end
116
+
117
+ optparse.parse!(ARGV)
118
+
119
+ vcs = VCLog::VCS.new
120
+
121
+ changelog = vcs.changelog
122
+
123
+ if typed
124
+ changelog = changelog.typed
125
+ end
126
+
127
+ case format
128
+ when :xml
129
+ log = changelog.format_xml(style) # xsl stylesheet url
130
+ when :html
131
+ log = changelog.format_html(style) # css stylesheet url
132
+ when :yaml
133
+ log = changelog.format_yaml
134
+ when :json
135
+ log = changelog.format_json
136
+ when :rel
137
+ file = changelog_file(output)
138
+ raise "no previous log to go by" unless file
139
+ log = changelog.format_rel(file, vers, nil, false)
140
+ when :rev
141
+ file = changelog_file(output)
142
+ raise "no previous log to go by" unless file
143
+ log = changelog.format_rel(file, vers, nil, true)
144
+ else #:gnu
145
+ log = changelog.to_s
146
+ end
147
+
148
+ if output
149
+ File.open(output, 'w') do |f|
150
+ f << log
151
+ end
152
+ else
153
+ puts log
154
+ end
155
+ end
156
+
157
+ def self.changelog_file(file)
158
+ if file && File.file?(file)
159
+ file
160
+ else
161
+ Dir.glob('{history,changes,changelog}{,.*}', File::FNM_CASEFOLD).first
162
+ end
163
+ end
164
+
165
+ end
166
+
167
+ # VCLog Copyright (c) 2008 Thomas Sawyer
168
+