vclog 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/HISTORY.rdoc +12 -2
  2. data/LICENSE +197 -17
  3. data/README.rdoc +11 -9
  4. data/bin/vclog +1 -1
  5. data/lib/plugins/syckle/vclog.rb +12 -12
  6. data/lib/vclog/adapters/abstract.rb +45 -16
  7. data/lib/vclog/adapters/darcs.rb +6 -1
  8. data/lib/vclog/adapters/git.rb +42 -2
  9. data/lib/vclog/adapters/hg.rb +15 -1
  10. data/lib/vclog/adapters/svn.rb +14 -0
  11. data/lib/vclog/adapters.rb +0 -17
  12. data/lib/vclog/change.rb +4 -0
  13. data/lib/vclog/cli/abstract.rb +22 -13
  14. data/lib/vclog/cli/autotag.rb +37 -0
  15. data/lib/vclog/cli/bump.rb +1 -1
  16. data/lib/vclog/cli/changelog.rb +2 -2
  17. data/lib/vclog/cli/{list.rb → formats.rb} +3 -3
  18. data/lib/vclog/cli/help.rb +15 -10
  19. data/lib/vclog/cli/history.rb +3 -4
  20. data/lib/vclog/cli/version.rb +1 -1
  21. data/lib/vclog/cli.rb +24 -188
  22. data/lib/vclog/facets.rb +2 -0
  23. data/lib/vclog/history.rb +1 -1
  24. data/lib/vclog/history_file.rb +64 -0
  25. data/lib/vclog/meta/data.rb +25 -0
  26. data/lib/vclog/meta/package +11 -0
  27. data/{PROFILE → lib/vclog/meta/profile} +6 -5
  28. data/lib/vclog/repo.rb +150 -0
  29. data/lib/vclog/tag.rb +2 -2
  30. data/lib/vclog/templates/changelog.html.erb +23 -18
  31. data/lib/vclog/templates/history.html.erb +4 -3
  32. data/lib/vclog.rb +3 -3
  33. data/man/man1/vclog-autotag.1 +23 -0
  34. data/man/man1/vclog-bump.1 +23 -0
  35. data/man/man1/vclog-changelog.1 +47 -0
  36. data/man/man1/vclog-history.1 +44 -0
  37. data/man/man1/vclog-version.1 +16 -0
  38. data/man/man1/vclog.1 +39 -0
  39. data/meta/data.rb +25 -0
  40. data/meta/package +11 -0
  41. data/meta/profile +18 -0
  42. data/ronn/index.txt +8 -0
  43. data/ronn/vclog-autotag.ronn +20 -0
  44. data/ronn/vclog-bump.ronn +21 -0
  45. data/ronn/vclog-changelog.ronn +39 -0
  46. data/ronn/vclog-history.ronn +38 -0
  47. data/ronn/vclog-version.ronn +14 -0
  48. data/ronn/vclog.ronn +36 -0
  49. metadata +39 -21
  50. data/REQUIRE +0 -11
  51. data/VERSION +0 -5
  52. data/lib/vclog/config.rb +0 -65
data/HISTORY.rdoc CHANGED
@@ -1,5 +1,15 @@
1
1
  = RELEASE HISTORY
2
2
 
3
+ == 1.8.0 / 2010-11-20
4
+
5
+ Under the hood, VCLog now has a Repo class that acts as a central controller. This has improved the code base substantially and should could to do so as this new design is further embraced. This release also introdces a new `autotag` feature, which makes it possible to "reverse engineer" a Release History file. It will parse the entries from a HISTORY.* file and ensure that corresponding tags exists in the version control system.
6
+
7
+ Changes:
8
+
9
+ * Add Repo class which acts as central control.
10
+ * Add autotag feature to ensure release history tags exits.
11
+
12
+
3
13
  == 1.7.0 / 2010-06-27
4
14
 
5
15
  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.
@@ -88,7 +98,7 @@ Changes:
88
98
  * Corrected error for --current and --bump commands.
89
99
 
90
100
 
91
- == 1.2 / 2009-10-26
101
+ == 1.2.0 / 2009-10-26
92
102
 
93
103
  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.
94
104
 
@@ -100,7 +110,7 @@ Changes:
100
110
  * Changed command-line interface.
101
111
 
102
112
 
103
- == 1.1 / 2009-10-23
113
+ == 1.1.0 / 2009-10-23
104
114
 
105
115
  This release adds yaml and json formats an improves
106
116
  the command.
data/LICENSE CHANGED
@@ -1,23 +1,203 @@
1
- The MIT License
2
1
 
3
- Copyright (c) 2009 Thomas Sawyer
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
4
5
 
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:
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
7
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
8
+ 1. Definitions.
14
9
 
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.
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
22
12
 
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
23
203
 
data/README.rdoc CHANGED
@@ -68,7 +68,7 @@ can create rules for labeling commit messages bassed on commit message.
68
68
  :admin
69
69
  end
70
70
 
71
- These rules can a also "massage" the commit message for output.
71
+ These rules can also "massage" the commit message for output.
72
72
 
73
73
  on /^admin:/ do |matchdata|
74
74
  [:admin, matchdate.post_match]
@@ -99,13 +99,15 @@ Please see HISTORY file.
99
99
 
100
100
  Copyright (c) 2009 Thomas Sawyer
101
101
 
102
- MIT License. See LICENSE or COPYING file for more details.
102
+ Licensed under the Apache License, Version 2.0 (the "License");
103
+ you may not use this file except in compliance with the License.
104
+ You may obtain a copy of the License at
103
105
 
104
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
110
- THE SOFTWARE.
106
+ http://www.apache.org/licenses/LICENSE-2.0
107
+
108
+ Unless required by applicable law or agreed to in writing, software
109
+ distributed under the License is distributed on an "AS IS" BASIS,
110
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
111
+ See the License for the specific language governing permissions and
112
+ limitations under the License.
111
113
 
data/bin/vclog CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'vclog/cli'
3
- VCLog::CLI.main(*ARGV)
3
+ VCLog.cli(*ARGV)
4
4
 
@@ -22,10 +22,10 @@ module Syckle::Plugins
22
22
 
23
23
  # Changelog format. Default is +html+.
24
24
  # Supports +html+, +xml+, +json+, +yaml+, +rdoc+, +markdown+, and +gnu+.
25
- attr_accessor :formats
25
+ attr_reader :formats
26
26
 
27
27
  # Changelog layout type (+changelog+ or +history+). Default is +changelog+.
28
- attr_accessor :type
28
+ attr_reader :type
29
29
 
30
30
  # Output directory store results.
31
31
  attr_accessor :output
@@ -47,8 +47,6 @@ module Syckle::Plugins
47
47
 
48
48
  #
49
49
  def initialize_defaults
50
- require 'vclog'
51
-
52
50
  @version = metadata.version
53
51
  @title = metadata.title
54
52
  @formats = ['atom']
@@ -82,6 +80,7 @@ module Syckle::Plugins
82
80
 
83
81
  #
84
82
  def document
83
+ require 'vclog'
85
84
  formats.each do |format|
86
85
  case type
87
86
  when 'rel', 'history'
@@ -136,18 +135,19 @@ module Syckle::Plugins
136
135
  # )
137
136
  #end
138
137
 
139
- def vclog_config
140
- @vclog_config ||= (
141
- vcf = VCLog::Config.new(project.root.to_s)
142
- vcf.level = level
143
- vcf
144
- )
145
- end
138
+ #def vclog_config
139
+ # @vclog_config ||= (
140
+ # vcf = VCLog::Config.new(project.root.to_s)
141
+ # vcf.level = level
142
+ # vcf
143
+ # )
144
+ #end
146
145
 
147
146
  # Access to version control system.
148
147
  def vcs
149
148
  #@vcs ||= VCLog::VCS.new #(self)
150
- @vcs ||= VCLog::Adapters.factory(vclog_config)
149
+ #@vcs ||= VCLog::Adapters.factory(vclog_config)
150
+ @vcs ||= VCLog::Repo.new(project.root.to_s, :level=>level)
151
151
  end
152
152
 
153
153
  # Convert log to desired format.
@@ -16,51 +16,74 @@ module Adapters
16
16
  # = Version Control System
17
17
  class Abstract
18
18
 
19
+ #
20
+ attr :config
21
+
19
22
  # Root location.
20
23
  attr :root
21
24
 
22
25
  # Heuristics object.
23
26
  attr :heuristics
24
27
 
25
- # Minimu change level.
28
+ # Minimum change level.
26
29
  attr :level
27
30
 
28
31
  #
29
- def initialize(config)
30
- @root = config.root # File.expand_path(config.root)
31
- @heuristics = config.heuristics
32
- @level = config.level.to_i
32
+ def initialize(repo)
33
+ @repo = repo
34
+
35
+ @root = repo.root
36
+ @heuristics = repo.heuristics
37
+ @level = repo.level
38
+
39
+ initialize_framework
40
+ end
41
+
42
+ # This is used if the adapter is using an external library
43
+ # to interface with the repository.
44
+ def initialize_framework
45
+ end
46
+
47
+ #
48
+ def extract_tags
49
+ raise "Not Implemented"
50
+ end
51
+
52
+ #
53
+ def extract_changes
54
+ raise "Not Implemented"
33
55
  end
34
56
 
35
57
  #
36
58
  def tags
37
59
  @tags ||= extract_tags.map{ |t| Tag===t ? t : Tag.new(*t) }
38
- end
60
+ end
39
61
 
40
62
  #
41
63
  # TODO: possbile to move heuristics lookup into Change class?
42
64
  def changes
43
- @changes ||= (
65
+ @changes ||= all_changes.select do |c|
66
+ c.level >= self.level
67
+ end
68
+ end
69
+
70
+ #
71
+ def all_changes
72
+ @all_changes ||= (
44
73
  changes = []
45
74
  extract_changes.each do |c|
46
75
  raise "how did this happen?" if Change == c
47
76
  rev, date, who, msg = *c
48
77
  type, level, label, nmsg = *heuristics.lookup(msg)
49
- next if level < self.level
50
78
  changes << Change.new(rev, date, who, nmsg||msg, type, level, label)
51
79
  end
52
80
  changes
53
- )
81
+ )
54
82
  end
55
83
 
56
84
  #
57
- def extract_tags
58
- raise "Not Implemented"
59
- end
60
-
61
- #
62
- def extract_changes
63
- raise "Not Implemented"
85
+ def tag?(name)
86
+ tags.find{ |t| t.name == name }
64
87
  end
65
88
 
66
89
  #
@@ -139,6 +162,12 @@ module Adapters
139
162
  return v
140
163
  end
141
164
 
165
+ # Return the latest commit as of a given date.
166
+ def change_by_date(date)
167
+ list = all_changes.select{ |c| c.date <= date }
168
+ list.sort_by{ |c| c.date }.last
169
+ end
170
+
142
171
  private
143
172
 
144
173
  #
@@ -7,7 +7,7 @@ module Adapters
7
7
  #
8
8
  # Provide Darcs SCM revision tools.
9
9
  #
10
- # TODO: This needs to be fixed.
10
+ # TODO: This needs to be fixed!!!!!!!
11
11
  #
12
12
  class Darcs < Abstract
13
13
 
@@ -77,6 +77,11 @@ module Adapters
77
77
  #format_version_stamp(ver, status) # ,released)
78
78
  end
79
79
 
80
+ # TODO
81
+ def tag(ref, label, msg)
82
+ `darcs tag #{label}`
83
+ end
84
+
80
85
  end
81
86
 
82
87
  end
@@ -1,12 +1,23 @@
1
1
  require 'vclog/adapters/abstract'
2
+ require 'tempfile'
2
3
 
3
4
  module VCLog
4
5
  module Adapters
5
6
 
6
- # = GIT Adapter
7
+ # The GIT Adapter utilizes the +grit+ gem.
7
8
  #
8
9
  class Git < Abstract
9
10
 
11
+ # TODO: in the future we might use grit, if it improves enough.
12
+ def initialize_framework
13
+ #require 'grit'
14
+ end
15
+
16
+ #
17
+ def grit_repo
18
+ @grit_repo ||= Grit::Repo.new(root)
19
+ end
20
+
10
21
  # Collect changes.
11
22
  #
12
23
  def extract_changes
@@ -23,6 +34,13 @@ module Adapters
23
34
  list
24
35
  end
25
36
 
37
+ # TODO
38
+ #def extract_changes
39
+ # repo.commit.map do |commit|
40
+ # [commit.id, commit.date, commit.author.to_s, commit.message]
41
+ # end
42
+ #end
43
+
26
44
  # Collect tags.
27
45
  #
28
46
  # `git show 1.0` produces:
@@ -74,23 +92,45 @@ module Adapters
74
92
  list
75
93
  end
76
94
 
95
+ # TODO: grit doesn't provide the tag information.
96
+ #def extract_tags
97
+ # list = grit_repo.tags.map do |tag|
98
+ # [tag.name, tag.commit.id, tag.commit.committed_date, tag.commit.author.to_s, tag.commit.message]
99
+ # end
100
+ # list
101
+ #end
102
+
77
103
  #
78
104
  def user
105
+ #@user ||= grit_repo.config['user.name']
79
106
  @user ||= `git config user.name`.strip
80
107
  end
81
108
 
82
109
  #
83
110
  def email
111
+ #@email ||= grit_repo.config['user.email']
84
112
  @email ||= `git config user.email`.strip
85
113
  end
86
114
 
87
115
  #
88
116
  def repository
117
+ #@repository ||= grit_repo.config['remote.origin.url']
89
118
  @repository ||= `git config remote.origin.url`.strip
90
119
  end
91
120
 
121
+ # Create a tag for the given commit reference.
122
+ def tag(ref, label, date, message)
123
+ mfile = Tempfile.new("message")
124
+ mfile.open{ |f| f << message }
125
+
126
+ date = date.strftime('%Y-%m-%d 23:59') unless String===date
127
+
128
+ cmd = %[GIT_AUTHOR_DATE='#{date}' GIT_COMMITTER_DATE='#{date}' git tag -a -F '#{mfile.path}' #{label} #{ref}]
129
+ puts cmd if $DEBUG
130
+ `#{cmd}` unless $DRYRUN
131
+ end
132
+
92
133
  end#class Git
93
134
 
94
135
  end
95
136
  end
96
-
@@ -5,6 +5,7 @@ module Adapters
5
5
 
6
6
  # = Mercurial Adapter
7
7
  #
8
+ # TODO: maybe use Amp gem for future version.
8
9
  class Hg < Abstract
9
10
 
10
11
  # Collect changes.
@@ -44,7 +45,7 @@ module Adapters
44
45
  ENV['HGEMAIL'] || ENV['EMAIL']
45
46
  end
46
47
 
47
- #
48
+ #
48
49
  def repository
49
50
  @repository ||= `hg showconfig paths.default`.strip
50
51
  end
@@ -54,6 +55,19 @@ module Adapters
54
55
  nil
55
56
  end
56
57
 
58
+ # TODO: Will multi-line messages work okay this way?
59
+ def tag(ref, label, date, msg)
60
+ mfile = Tempfile.new("message")
61
+ mfile.open{ |f| f << msg }
62
+
63
+ date = date.strftime('%Y-%m-%d') unless String===date
64
+
65
+ cmd = %[hg tag -r #{ref} -d #{date} -m "$(cat #{mfile.path})" #{label}]
66
+
67
+ puts cmd if $DEBUG
68
+ `#{cmd}` unless $DRYRUN
69
+ end
70
+
57
71
  private
58
72
 
59
73
  def parse_entry(entry)
@@ -127,6 +127,20 @@ module Adapters
127
127
  info['Repository UUID']
128
128
  end
129
129
 
130
+ #
131
+ def tag(ref, label, date, message)
132
+ mfile = Tempfile.new("message")
133
+ mfile.open{ |f| f << message }
134
+
135
+ Dir.chdir(root) do
136
+ cmd = %[svn copy -r #{ref} -F "#{mfile.path}" . #{tag_directory}/#{label}]
137
+ puts cmd if $DEBUG
138
+ `#{cmd}` unless $DRYRUN
139
+ end
140
+ end
141
+
142
+ private
143
+
130
144
  #
131
145
  def info
132
146
  @info ||= YAML.load(`svn info`.strip)
@@ -6,23 +6,6 @@ require 'vclog/adapters/hg'
6
6
  module VCLog
7
7
 
8
8
  module Adapters
9
-
10
- #
11
- def self.factory(config) #, options={})
12
- type = read_type(config.root)
13
- raise ArgumentError, "Not a recognized version control system." unless type
14
- const_get(type.capitalize).new(config) #, options)
15
- end
16
-
17
- #
18
- def self.read_type(root)
19
- dir = nil
20
- Dir.chdir(root) do
21
- dir = Dir.glob("{.svn,.git,.hg,_darcs}").first
22
- end
23
- dir[1..-1] if dir
24
- end
25
-
26
9
  end
27
10
 
28
11
  end
data/lib/vclog/change.rb CHANGED
@@ -33,6 +33,10 @@ module VCLog
33
33
  @author = author.strip
34
34
  end
35
35
 
36
+ # Alternate name for revision.
37
+ alias_method :rev, :revision
38
+ alias_method :rev=, :revision=
39
+
36
40
  #def clean_type(type)
37
41
  # case type.to_s
38
42
  # when 'maj', 'major' then :major