Permalink
Browse files

bug: fixed delta groupings and other improvements

  • Loading branch information...
trans committed May 28, 2010
1 parent 98f30c2 commit 79be281a80d2c1df44312ff338d9d1c8c4c116d4
@@ -2,6 +2,7 @@ module VCLog
module Adapters
require 'time'
+ require 'vclog/formatter'
require 'vclog/changelog'
require 'vclog/history'
require 'vclog/change'
@@ -48,6 +49,12 @@ def history(opts={})
@history ||= History.new(self, opts)
end
+ #
+ def display(type, format, options={})
+ formatter = Formatter.new(self)
+ formatter.display(type, format, options)
+ end
+
# Provides a bumped version number.
def bump(part=nil)
return part unless ['major', 'minor', 'patch', ''].include?(part.to_s)
@@ -83,6 +90,12 @@ def bump(part=nil)
private
+ #
+ def version_tag?(tag_name)
+ /(v|\d)/i =~ tag_name
+ end
+
+=begin
# Looks for a "[type]" indicator at the end of the commit message.
# If that is not found, it looks at front of message for
# "[type]" or "[type]:". Failing that it tries just "type:".
@@ -104,6 +117,7 @@ def split_type(note)
n.gsub!(/^\s*?\n/m,'') # remove blank lines
return n, t
end
+=end
=begin
# Write the ChangeLog to file.
@@ -143,6 +157,26 @@ def format_version_stamp( version, status=nil, date=nil )
end
=end
+ #
+ def user
+ ENV['USER']
+ end
+
+ #
+ def email
+ ENV['EMAIL']
+ end
+
+ #
+ def repository
+ nil
+ end
+
+ #
+ def uuid
+ nil
+ end
+
end
end
View
@@ -7,19 +7,6 @@ module Adapters
#
class Git < Abstract
- #def initialize
- #end
-
- #
- #def changelog
- # @changelog ||= ChangeLog.new(changes)
- #end
-
- #
- #def history(opts={})
- # @history ||= History.new(self, opts)
- #end
-
# Collect changes.
#
def extract_changes
@@ -31,8 +18,7 @@ def extract_changes
changes.each do |entry|
date, who, rev, msg = entry.split('|~|')
date = Time.parse(date)
- msg, type = *split_type(msg)
- list << [rev, date, who, msg, type]
+ list << [rev, date, who, msg]
end
list
end
@@ -53,15 +39,16 @@ def extract_tags
list = []
tags = `git tag -l`
tags.split(/\s+/).each do |tag|
+ next unless version_tag?(tag) # only version tags
info = `git show #{tag}`
md = /\Atag(.*?)\n(.*?)^commit/m.match(info)
who, date, *msg = *md[2].split(/\n/)
who = who.split(':')[1].strip
date = date[date.index(':')+1..-1].strip
msg = msg.join("\n")
- info = `git show #{tag}^ --pretty=format:"%ci|-|%H|-|"`
- date, rev, *_ = *info.split('|-|')
+ info = `git show #{tag}^ --pretty=format:"%ci|~|%H|~|"`
+ date, rev, *_ = *info.split('|~|')
#md = /\Atag(.*?)\n(.*?)^commit/m.match(info)
#_who, _date, *_msg = *md[2].split(/\n/)
@@ -74,6 +61,21 @@ def extract_tags
list
end
+ #
+ def user
+ @email ||= `git config user.name`.strip
+ end
+
+ #
+ def email
+ @email ||= `git config user.email`.strip
+ end
+
+ #
+ def repository
+ @repository ||= `git config remote.origin.url`.strip
+ end
+
end#class Git
end
View
@@ -34,27 +34,48 @@ def extract_tags
list
end
+ # TODO: check .hgrc
+ def user
+ ENV['HGUSER'] || ENV['USER']
+ end
+
+ #
+ def email
+ ENV['HGEMAIL'] || ENV['EMAIL']
+ end
+
+ #
+ def repository
+ @repository ||= `hg showconfig paths.default`.strip
+ end
+
+ #
+ def uuid
+ nil
+ end
+
private
- def parse_entry(entry)
- rev, date, who, msg = nil, nil, nil, nil
- entry.strip!
- if md = /^changeset:(.*?)$/.match(entry)
- rev = md[1].strip
- end
- if md = /^date:(.*?)$/.match(entry)
- date = md[1].strip
- end
- if md = /^user:(.*?)$/.match(entry)
- who = md[1].strip
- end
- if md = /^description:(.*?)\Z/m.match(entry)
- msg = md[1].strip
+ def parse_entry(entry)
+ rev, date, who, msg = nil, nil, nil, nil
+ entry.strip!
+ if md = /^changeset:(.*?)$/.match(entry)
+ rev = md[1].strip
+ end
+ if md = /^date:(.*?)$/.match(entry)
+ date = md[1].strip
+ end
+ if md = /^user:(.*?)$/.match(entry)
+ who = md[1].strip
+ end
+ if md = /^description:(.*?)\Z/m.match(entry)
+ msg = md[1].strip
+ end
+ date = Time.parse(date)
+ msg, type = *split_type(msg)
+ return rev, date, who, msg, type
end
- date = Time.parse(date)
- msg, type = *split_type(msg)
- return rev, date, who, msg, type
- end
+
end
end
View
@@ -109,6 +109,31 @@ def tag_directory
fnd
end
+ #
+ def user
+ @email ||= `svn propget svn:author`.strip
+ end
+
+ # TODO: Best solution to SVN email?
+ def email
+ @email ||= ENV['EMAIL']
+ end
+
+ #
+ def repository
+ info['Repository Root']
+ end
+
+ #
+ def uuid
+ info['Repository UUID']
+ end
+
+ #
+ def info
+ @info ||= YAML.load(`svn info`.strip)
+ end
+
end
end
View
@@ -13,7 +13,7 @@ class Change
attr_accessor :type
#
- def initialize(rev, date, author, message, type=nil)
+ def initialize(rev, date, author, message)
self.revision = rev
self.date = date
self.author = author
@@ -28,12 +28,7 @@ def author=(author)
#
def message=(note)
- @message = note.strip
- end
-
- #
- def type
- @type ||= split_type(message)
+ @message, @type = split_type(note)
end
#def clean_type(type)
@@ -95,19 +90,19 @@ def inspect
def to_h
{ 'author' => @author,
'date' => @date,
- 'revision' => @revison,
+ 'revision' => @revision,
'message' => @message,
'type' => @type
}
end
- def to_json
- to_h.to_json
- end
+ #def to_json
+ # to_h.to_json
+ #end
- def to_yaml(*args)
- to_h.to_yaml(*args)
- end
+ #def to_yaml(*args)
+ # to_h.to_yaml(*args)
+ #end
private
@@ -116,7 +111,7 @@ def to_yaml(*args)
# "[type]" or "[type]:". Failing that it tries just "type:".
#
def split_type(note)
- note = note.strip
+ note = note.to_s.strip
if md = /\[(.*?)\]\Z/.match(note)
t = md[1].strip.downcase
n = note[0...(md.begin(0))]
View
@@ -55,9 +55,20 @@ def change(rev, date, who, note, type=nil)
@changes << Change.new(rev, date, who, note, type)
end
- def each(&block) ; changes.each(&block) ; end
- def empty? ; changes.empty? ; end
- def size ; changes.size ; end
+ #
+ def each(&block)
+ changes.each(&block)
+ end
+
+ #
+ def empty?
+ changes.empty?
+ end
+
+ #
+ def size
+ changes.size
+ end
#
def <<(entry)
@@ -126,6 +137,11 @@ def by_date
# mapped
#end
+ def to_h
+ map{ |change| change.to_h }
+ end
+
+
# O U T P U T F O R M A T S
#
@@ -152,6 +168,7 @@ def by_date
# return x.join("\n")
# end
+=begin
#
def to_gnu(rev=false)
@@ -173,7 +190,9 @@ def to_json
require 'json'
changes.to_json
end
+=end
+=begin
#
alias_method :to_s, :to_gnu
@@ -209,6 +228,7 @@ def to_markdown(rev=false)
erb = ERB.new(tmp)
erb.result(binding)
end
+=end
=begin
# Create an XML formated changelog.
Oops, something went wrong.

0 comments on commit 79be281

Please sign in to comment.