rubycut-vclog 1.9.4

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 (76) hide show
  1. data/.yardopts +7 -0
  2. data/History.md +249 -0
  3. data/License.txt +23 -0
  4. data/README.md +133 -0
  5. data/bin/vclog +6 -0
  6. data/bin/vclog-autotag +6 -0
  7. data/bin/vclog-bump +6 -0
  8. data/bin/vclog-formats +6 -0
  9. data/bin/vclog-news +6 -0
  10. data/bin/vclog-version +6 -0
  11. data/lib/vclog.rb +6 -0
  12. data/lib/vclog.yml +68 -0
  13. data/lib/vclog/adapters.rb +12 -0
  14. data/lib/vclog/adapters/abstract.rb +131 -0
  15. data/lib/vclog/adapters/darcs.rb +93 -0
  16. data/lib/vclog/adapters/git.rb +190 -0
  17. data/lib/vclog/adapters/hg.rb +129 -0
  18. data/lib/vclog/adapters/svn.rb +155 -0
  19. data/lib/vclog/change.rb +207 -0
  20. data/lib/vclog/change_point.rb +77 -0
  21. data/lib/vclog/changelog.rb +233 -0
  22. data/lib/vclog/cli.rb +8 -0
  23. data/lib/vclog/cli/abstract.rb +92 -0
  24. data/lib/vclog/cli/autotag.rb +36 -0
  25. data/lib/vclog/cli/bump.rb +29 -0
  26. data/lib/vclog/cli/formats.rb +28 -0
  27. data/lib/vclog/cli/log.rb +86 -0
  28. data/lib/vclog/cli/news.rb +29 -0
  29. data/lib/vclog/cli/version.rb +30 -0
  30. data/lib/vclog/config.rb +143 -0
  31. data/lib/vclog/core_ext.rb +11 -0
  32. data/lib/vclog/heuristics.rb +192 -0
  33. data/lib/vclog/heuristics/rule.rb +73 -0
  34. data/lib/vclog/heuristics/type.rb +29 -0
  35. data/lib/vclog/history_file.rb +69 -0
  36. data/lib/vclog/metadata.rb +16 -0
  37. data/lib/vclog/rc.rb +9 -0
  38. data/lib/vclog/release.rb +67 -0
  39. data/lib/vclog/repo.rb +298 -0
  40. data/lib/vclog/report.rb +200 -0
  41. data/lib/vclog/tag.rb +151 -0
  42. data/lib/vclog/templates/changelog.ansi.rb +35 -0
  43. data/lib/vclog/templates/changelog.atom.erb +52 -0
  44. data/lib/vclog/templates/changelog.gnu.rb +24 -0
  45. data/lib/vclog/templates/changelog.html.erb +49 -0
  46. data/lib/vclog/templates/changelog.json.rb +1 -0
  47. data/lib/vclog/templates/changelog.markdown.rb +30 -0
  48. data/lib/vclog/templates/changelog.rdoc.rb +30 -0
  49. data/lib/vclog/templates/changelog.rss.erb +54 -0
  50. data/lib/vclog/templates/changelog.xml.erb +28 -0
  51. data/lib/vclog/templates/changelog.xsl +34 -0
  52. data/lib/vclog/templates/changelog.yaml.rb +1 -0
  53. data/lib/vclog/templates/history.ansi.rb +57 -0
  54. data/lib/vclog/templates/history.atom.erb +84 -0
  55. data/lib/vclog/templates/history.gnu.rb +39 -0
  56. data/lib/vclog/templates/history.html.erb +60 -0
  57. data/lib/vclog/templates/history.json.rb +1 -0
  58. data/lib/vclog/templates/history.markdown.rb +38 -0
  59. data/lib/vclog/templates/history.rdoc.rb +36 -0
  60. data/lib/vclog/templates/history.rss.erb +84 -0
  61. data/lib/vclog/templates/history.xml.erb +43 -0
  62. data/lib/vclog/templates/history.yaml.rb +1 -0
  63. data/man/man1/index.txt +9 -0
  64. data/man/man1/vclog-autotag.1.ronn +29 -0
  65. data/man/man1/vclog-bump.1.ronn +21 -0
  66. data/man/man1/vclog-news.1.ronn +25 -0
  67. data/man/man1/vclog-version.1.ronn +14 -0
  68. data/man/man1/vclog.1.ronn +49 -0
  69. data/spec/feature_git_changes.rb +58 -0
  70. data/spec/feature_git_history.rb +58 -0
  71. data/spec/feature_hg_changes.rb +58 -0
  72. data/spec/feature_hg_history.rb +58 -0
  73. data/spec/featurettes/repo_creation.rb +64 -0
  74. data/spec/featurettes/shellout.rb +16 -0
  75. data/test/case_metadata.rb +10 -0
  76. metadata +265 -0
@@ -0,0 +1,29 @@
1
+ require 'vclog/cli/abstract'
2
+
3
+ module VCLog::CLI
4
+
5
+ #
6
+ class Bump < Abstract
7
+
8
+ #
9
+ def self.terms
10
+ ['bump']
11
+ end
12
+
13
+ #
14
+ def parser
15
+ super do |opt|
16
+ opt.banner = "Usage: vclog-bump"
17
+ opt.separator(" ")
18
+ opt.separator("Display a bumped version number.")
19
+ end
20
+ end
21
+
22
+ #
23
+ def execute
24
+ puts repo.bump #(version)
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,28 @@
1
+ require 'vclog/cli/abstract'
2
+
3
+ module VCLog::CLI
4
+
5
+ # Command to display a list of available formats.
6
+ #
7
+ class Formats < Abstract
8
+
9
+ #
10
+ def self.terms
11
+ ['formats', 'templates']
12
+ end
13
+
14
+ #
15
+ def parser
16
+ super do |opt|
17
+ opt.banner = "Usage: vclog-formats"
18
+ end
19
+ end
20
+
21
+ #
22
+ def execute
23
+ puts " ansi gnu rdoc markdown xml html atom rss json yaml"
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,86 @@
1
+ require 'vclog/cli/abstract'
2
+
3
+ module VCLog::CLI
4
+
5
+ # VCLog provides cross-vcs ChangeLogs. It works by
6
+ # parsing the native changelog a VCS system produces
7
+ # into a common model, which then can be used to
8
+ # produce Changelogs in a variety of formats.
9
+ #
10
+ # VCLog currently support git, hg and svn, with cvs and
11
+ # darcs in the works.
12
+ #
13
+ # To produce a GNU-like changelog:
14
+ #
15
+ # $ vclog
16
+ #
17
+ # For XML format:
18
+ #
19
+ # $ vclog -f xml
20
+ #
21
+ # Or for a micorformat-ish HTML:
22
+ #
23
+ # $ vclog -f html
24
+ #
25
+ # To use the library programmatically, please see the API documentation.
26
+ #
27
+ class Log < Abstract
28
+
29
+ # Setup options for log command.
30
+ #
31
+ # Returns a instance of OptionParser.
32
+ def parser
33
+ super do |parser|
34
+ parser.banner = 'Usage: vclog [options]'
35
+ parser.separator(' ')
36
+ parser.separator('Print a change log or release history.')
37
+ parser.separator(' ')
38
+ parser.separator('OPTIONS: (use varies with format)')
39
+ parser.on('-f', '--format FORMAT', 'output format (ansi,gnu,html,...)') do |format|
40
+ options[:format] = format.to_sym
41
+ end
42
+ parser.on('-r', '--release', '--history', 'show release history, instead of changelog') do
43
+ options[:type] = :history
44
+ end
45
+ parser.on('-t', '--title TITLE', 'document title') do |string|
46
+ options[:title] = string
47
+ end
48
+ parser.on('-v', '--version NUM', 'use as current version number') do |num|
49
+ options[:version] = num
50
+ end
51
+ parser.on('-l', '--level NUMBER', 'lowest level of commit to display (default: 0)') do |num|
52
+ options[:level] = num.to_i
53
+ end
54
+ parser.on('-p', '--point', 'split commit message into per-point entries') do
55
+ options[:point] = true
56
+ end
57
+ parser.separator(' ')
58
+ parser.separator('XML/HTML OPTIONS: (applies only to xml/html formats)')
59
+ parser.on('-S', '--style URI', 'provide a stylesheet URI (css or xsl)') do |uri|
60
+ options[:stylesheet] = uri
61
+ end
62
+ parser.separator(' ')
63
+ parser.separator('TEXT OPTIONS: (applies only to text formats)')
64
+ parser.on('-i', '--id', 'include reference/revision id in output') do
65
+ options[:reference] = true # TODO: change to :id ?
66
+ end
67
+ parser.on('-d', '--detail', 'include commit message details (no effect if -p)') do
68
+ options[:detail] = true
69
+ end
70
+ parser.on('-s', '--summary', 'exclude commit messages from report') do
71
+ options[:summary] = true
72
+ end
73
+ #parser.on('--typed', "catagorize by commit type") do
74
+ # typed = true
75
+ #end
76
+ end
77
+ end
78
+
79
+ #
80
+ def execute
81
+ puts repo.report(options)
82
+ end
83
+
84
+ end
85
+
86
+ end
@@ -0,0 +1,29 @@
1
+ require 'vclog/cli/abstract'
2
+
3
+ module VCLog::CLI
4
+
5
+ #
6
+ class News < Abstract
7
+
8
+ #
9
+ def self.terms
10
+ ['news']
11
+ end
12
+
13
+ #
14
+ def parser
15
+ super do |opt|
16
+ opt.banner = "Usage: vclog-news"
17
+ opt.separator(" ")
18
+ opt.separator("Display first release note from history file.")
19
+ end
20
+ end
21
+
22
+ #
23
+ def execute
24
+ puts repo.history_file.news #(version)
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,30 @@
1
+ require 'vclog/cli/abstract'
2
+
3
+ module VCLog::CLI
4
+
5
+ # Display the current version.
6
+ #
7
+ class Version < Abstract
8
+
9
+ #
10
+ def self.terms
11
+ ['version']
12
+ end
13
+
14
+ #
15
+ def parser
16
+ super do |opt|
17
+ opt.banner = "Usage: vclog version"
18
+ opt.separator(" ")
19
+ opt.separator("Display the current version number.")
20
+ end
21
+ end
22
+
23
+ #
24
+ def execute
25
+ puts repo.version
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,143 @@
1
+ require 'vclog/heuristics'
2
+ #require 'vclog/rc'
3
+
4
+ module VCLog
5
+
6
+ # Get/set master configruation(s).
7
+ def self.configure(&block)
8
+ @config ||= []
9
+ @config << block if block
10
+ @config
11
+ end
12
+
13
+ # Encapsulates configuration settings for running vclog.
14
+ #
15
+ # We recommend putting vclog configuration in a project's `etc/vclog.rb`
16
+ # file. For Rails projects, however, `config/vclog.rb` can be used. If
17
+ # usig a subdirectory is not suitable to a project then simply using
18
+ # the more traditional `.vclog` file works too.
19
+ #
20
+ class Config
21
+
22
+ # File glob for identifying the project's root directory.
23
+ #
24
+ # NOTE: SVN support is limited to repos with a trunk directory.
25
+ ROOT_GLOB = "{.git,.hg,_darcs,.svn/trunk}"
26
+
27
+ #
28
+ # Default vclog config file glob looks for these possible matches:
29
+ #
30
+ # * vclog.rb
31
+ # * etc/vclog.rb
32
+ # * config/vclog.rb
33
+ #
34
+ # The configuration file can also be a hidden dot file if preferred:
35
+ #
36
+ # * .vclog
37
+ # * .etc/vclog.rb
38
+ # * .config/vclog.rb
39
+ #
40
+ # Root files have precedence over files in subdirectories, and the `.rb`
41
+ # file extension is optional in all cases.
42
+ #
43
+ FILE_GLOBS = [ '{,.}vclog{,.rb}', '{.,}{etc/,config/}vclog{,.rb}' ]
44
+
45
+ #
46
+ #
47
+ #
48
+ def initialize(options={})
49
+ @root = options[:root] || lookup_root
50
+ @level = options[:level] || 0
51
+ @force = options[:force] || false
52
+ @version = options[:version]
53
+ end
54
+
55
+ #
56
+ # Project's root directory.
57
+ #
58
+ attr :root
59
+
60
+ #
61
+ # Default change level.
62
+ #
63
+ def level
64
+ heuristics.level
65
+ end
66
+
67
+ #
68
+ # Force mode active?
69
+ #
70
+ def force?
71
+ @force
72
+ end
73
+
74
+ #
75
+ # Indicates the version of HEAD.
76
+ #
77
+ def version
78
+ @version
79
+ end
80
+
81
+ #
82
+ # Load heuristics.
83
+ #
84
+ def heuristics
85
+ @heuristics ||= (
86
+ if file
87
+ Heuristics.load(file)
88
+ else
89
+ h = Heuristics.new
90
+ if config = VCLog.configure
91
+ config.each{ |c| c.call(h) }
92
+ end
93
+ h
94
+ end
95
+ )
96
+ end
97
+
98
+ #
99
+ # Which version control system?
100
+ #
101
+ def vcs_type
102
+ @vcs_type ||= (
103
+ dir = nil
104
+ Dir.chdir(root) do
105
+ dir = Dir.glob("{.git,.hg,.svn,_darcs}").first
106
+ end
107
+ dir[1..-1] if dir
108
+ )
109
+ end
110
+
111
+ #
112
+ # The vclog config file.
113
+ #
114
+ def file
115
+ #DEFAULT_GLOBS.find{ |g| Dir.glob(g).first }
116
+ end
117
+
118
+ #
119
+ # Find project root. This searches up from the current working
120
+ # directory for a source control manager directory.
121
+ #
122
+ # * `.git/`
123
+ # * `.hg/`
124
+ # * `_darcs/`
125
+ # * `.svn/trunk`
126
+ #
127
+ # If all else fails the current directory is returned.
128
+ #
129
+ def lookup_root
130
+ root = nil
131
+ Dir.ascend(Dir.pwd) do |path|
132
+ check = Dir[ROOT_GLOB].first
133
+ if check
134
+ root = path
135
+ break
136
+ end
137
+ end
138
+ root || Dir.pwd
139
+ end
140
+
141
+ end
142
+
143
+ end
@@ -0,0 +1,11 @@
1
+ require 'facets/string/fold'
2
+ require 'facets/string/indent'
3
+ require 'facets/string/tabto'
4
+ require 'facets/string/margin'
5
+ require 'facets/enumerable/group_by'
6
+ require 'facets/kernel/ask'
7
+
8
+ class OpenStruct
9
+ method_undef(:type) if method_defined?(:type)
10
+ end
11
+
@@ -0,0 +1,192 @@
1
+ require 'vclog/heuristics/type'
2
+ require 'vclog/heuristics/rule'
3
+
4
+ module VCLog
5
+
6
+ # Heuristics stores a set of rules to be applied to commmits
7
+ # in order to assign them priority levels and report labels.
8
+ #
9
+ class Heuristics
10
+
11
+ #
12
+ # Load heuristics from a designated file.
13
+ #
14
+ # @param [String] file
15
+ # Configuration file.
16
+ #
17
+ def self.load(file)
18
+ raise LoadError unless File.exist?(file)
19
+ new{ instance_eval(File.read(file), file) }
20
+ end
21
+
22
+ #
23
+ # Load heuristics given a script.
24
+ #
25
+ # @param [String] script
26
+ # Configuration script.
27
+ #
28
+ def self.eval(script, file='(eval)', line=0)
29
+ new{ instance_eval(text, file, line) }
30
+ end
31
+
32
+ #
33
+ # Initialize new heurtistics set.
34
+ #
35
+ def initialize(&block)
36
+ @rules = []
37
+
38
+ @types = Hash.new{ |h,k| h[k] = h[:default] }
39
+ @types[:default] = Type.new(:default, -1, "Nominal Changes")
40
+
41
+ @colors = [:blue, :blue, :cyan, :green, :yellow, :red, :red]
42
+
43
+ if block
44
+ instance_eval(&block)
45
+ else
46
+ default
47
+ end
48
+ end
49
+
50
+ #
51
+ # Apply heuristics to a commit.
52
+ #
53
+ # @param [Change] commit
54
+ # Instance of Change encapsulates an SCM commit.
55
+ #
56
+ def apply(commit)
57
+ # apply rules, breaking on first rule found that fits.
58
+ @rules.find{ |rule| rule.call(commit) }
59
+
60
+ unless commit.level
61
+ commit.level = types[commit.type].level
62
+ end
63
+
64
+ unless commit.label
65
+ commit.label = types[commit.type].label
66
+ end
67
+
68
+ # apply color for commit level
69
+ color = @colors[commit.level + (@colors.size / 2)]
70
+ color ||= (commit.level > 0 ? @colors.first : @colors.last)
71
+ commit.color = color
72
+ end
73
+
74
+ #
75
+ # Define a new rule.
76
+ #
77
+ def on(pattern=nil, &block)
78
+ @rules << Rule.new(pattern, &block)
79
+ end
80
+
81
+ #
82
+ # Convenience method for setting-up commit types, which can
83
+ # be easily assigned, setting both label and level in one go.
84
+ #
85
+ def type(type, level, label)
86
+ @types[type.to_sym] = Type.new(type, level, label)
87
+ end
88
+
89
+ # @deprecated
90
+ alias_method :set, :type
91
+
92
+ #
93
+ # Access to defined types.
94
+ #
95
+ # @example
96
+ # commit.type = :major
97
+ #
98
+ attr :types
99
+
100
+ #
101
+ # Set color list. The center element cooresponds to `level=0`.
102
+ # Elements before the center are incrementally higher levels
103
+ # and those after are lower.
104
+ #
105
+ # @example
106
+ # colors :red, :yellow, :green, :cyan, :blue
107
+ #
108
+ def colors(*list)
109
+ @colors = list
110
+ end
111
+
112
+ #
113
+ # Set default level.
114
+ #
115
+ def level(integer=nil)
116
+ @level = integer.to_i is integer
117
+ @level
118
+ end
119
+
120
+ #
121
+ # Default settings.
122
+ #
123
+ def default
124
+ type :major, 3, "Major Enhancements"
125
+ type :minor, 2, "Minor Enhancements"
126
+ type :bug, 1, "Bug Fixes"
127
+ type :default, 0, "Nominal Changes"
128
+ type :doc, -1, "Documentation Changes"
129
+ type :test, -2, "Test/Spec Adjustments"
130
+ type :admin, -3, "Administrative Changes"
131
+
132
+ on /\A(\w+):/ do |commit, md|
133
+ type = md[1].to_sym
134
+ commit.type = type
135
+ commit.message = commit.message.sub(md[0],'').strip
136
+ true
137
+ end
138
+
139
+ on /\[(\w+)\]\s*$/ do |commit, md|
140
+ type = md[1].to_sym
141
+ commit.type = type
142
+ commit.message = commit.message.sub(md[0],'').strip
143
+ true
144
+ end
145
+
146
+ on /updated? (README|PROFILE|PACKAGE|VERSION|MANIFEST)/ do |commit|
147
+ commit.type = :admin
148
+ end
149
+
150
+ on /(bump|bumped|prepare) version/ do |commit|
151
+ commit.type = :admin
152
+ end
153
+ end
154
+
155
+ #
156
+ # Work on next-gen default heuristics.
157
+ #
158
+ def default2
159
+ type :major, 3, "Major Enhancements"
160
+ type :minor, 2, "Minor Enhancements"
161
+ type :bug, 1, "Bug Fixes"
162
+ type :default, 0, "Nominal Changes"
163
+ type :doc, -1, "Documentation Changes"
164
+ type :test, -2, "Test/Spec Adjustments"
165
+ type :admin, -3, "Administrative Changes"
166
+
167
+ # test/spec file only changes
168
+ on do |commit|
169
+ if commit.files.all?{ |f| f.start_with?('test') || f.start_with?('spec') }
170
+ commit.type = :test
171
+ end
172
+ end
173
+ end
174
+
175
+ private
176
+
177
+ # TODO: applies types that are "close", to help overlook typos.
178
+ #
179
+ #def close_type(type)
180
+ # case type.to_s
181
+ # when 'maj', 'major' then :major
182
+ # when 'min', 'minor' then :minor
183
+ # when 'bug' then :bug
184
+ # when '' then :other
185
+ # else
186
+ # type.to_sym
187
+ # end
188
+ #end
189
+
190
+ end
191
+
192
+ end