vclog 1.8.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,17 @@
1
1
  = RELEASE HISTORY
2
2
 
3
- == 1.8.0 / 2010-11-20
3
+ == 1.8.1 / 2010-11-22
4
+
5
+ This release corrects the tag dates on Histories. Where possible the tag date is used rather than the commit date (of the most recent commit made relative to the tag). Primarily this effects git repositories --a separate tag date is not supported by all SCMs. This release also fixes a bug in the hg adapter that prevented auto-tagging.
6
+
7
+ Changes:
8
+
9
+ * Use tag date instead of commit date in history.
10
+ * Fix typo in hg adapter's autotag method.
11
+ * Add history file option to autotag command.
12
+
13
+
14
+ == 1.8.0 / 2010-11-21
4
15
 
5
16
  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
17
 
@@ -1,7 +1,8 @@
1
1
  = VCLog
2
2
 
3
- * home: http://proutils.github.com/vclog
4
- * work: http://github.com/proutils/vclog
3
+ * home: http://rubyworks.github.com/vclog
4
+ * code: http://github.com/rubyworks/vclog
5
+ * talk: http://googlegroups.com/group/rubyworks-mailinglist
5
6
 
6
7
 
7
8
  == DESCRIPTION
@@ -3,6 +3,7 @@ module Adapters
3
3
 
4
4
  require 'time'
5
5
  require 'pathname'
6
+ require 'tempfile'
6
7
 
7
8
  require 'vclog/formatter'
8
9
  require 'vclog/changelog'
@@ -56,7 +57,7 @@ module Adapters
56
57
 
57
58
  #
58
59
  def tags
59
- @tags ||= extract_tags.map{ |t| Tag===t ? t : Tag.new(*t) }
60
+ @tags ||= extract_tags
60
61
  end
61
62
 
62
63
  #
@@ -71,11 +72,13 @@ module Adapters
71
72
  def all_changes
72
73
  @all_changes ||= (
73
74
  changes = []
74
- extract_changes.each do |c|
75
- raise "how did this happen?" if Change == c
76
- rev, date, who, msg = *c
77
- type, level, label, nmsg = *heuristics.lookup(msg)
78
- changes << Change.new(rev, date, who, nmsg||msg, type, level, label)
75
+ extract_changes.each do |change|
76
+ #raise "how did this happen?" if Change == c
77
+ #rev, date, who, msg = *c
78
+ #type, level, label, nmsg = *heuristics.lookup(msg)
79
+ #Change.new(rev, date, who, nmsg||msg, type, level, label)
80
+ change.apply_heuristics(heuristics)
81
+ changes << change
79
82
  end
80
83
  changes
81
84
  )
@@ -175,6 +178,13 @@ module Adapters
175
178
  /(v|\d)/i =~ tag_name
176
179
  end
177
180
 
181
+ #
182
+ def tempfile(name, content)
183
+ mfile = Tempfile.new(name)
184
+ File.open(mfile.path, 'w'){ |f| f << content }
185
+ mfile.path
186
+ end
187
+
178
188
  =begin
179
189
  # Looks for a "[type]" indicator at the end of the commit message.
180
190
  # If that is not found, it looks at front of message for
@@ -1,5 +1,4 @@
1
1
  require 'vclog/adapters/abstract'
2
- require 'tempfile'
3
2
 
4
3
  module VCLog
5
4
  module Adapters
@@ -27,9 +26,9 @@ module Adapters
27
26
  #changes = changelog.split(/^commit/m)
28
27
  changes.shift # throw the first (empty) entry away
29
28
  changes.each do |entry|
30
- date, who, rev, msg = entry.split('|~|')
29
+ date, who, id, msg = entry.split('|~|')
31
30
  date = Time.parse(date)
32
- list << [rev, date, who, msg]
31
+ list << Change.new(:id=>id, :date=>date, :who=>who, :msg=>msg)
33
32
  end
34
33
  list
35
34
  end
@@ -66,20 +65,21 @@ module Adapters
66
65
  info.lines.to_a[1..-1].each do |line|
67
66
  case line
68
67
  when /^Tagger:/
69
- who = $'
68
+ who = $'.strip
70
69
  when /^Date:/
71
- date = $'
70
+ date = $'.strip
72
71
  else
73
72
  msg << line
74
73
  end
75
74
  end
76
75
  msg = msg.strip
77
76
  info = `git show #{tag}^ --pretty=format:"%ci|~|%H|~|"`
78
- date, rev, *_ = *info.split('|~|')
77
+ cdate, id, *_ = *info.split('|~|')
79
78
  else
80
79
  info = `git show #{tag} --pretty=format:"%cn|~|%ce|~|%ci|~|%H|~|%s|~|"`
81
- who, email, date, rev, msg, *_ = *info.split('|~|')
82
- who = who + ' ' + email
80
+ who, email, cdate, id, msg, *_ = *info.split('|~|')
81
+ who = who + ' ' + email
82
+ date = cdate
83
83
  end
84
84
 
85
85
  #if $DEBUG
@@ -87,7 +87,7 @@ module Adapters
87
87
  # puts
88
88
  #end
89
89
 
90
- list << [tag, rev, date, who, msg]
90
+ list << Tag.new(:name=>tag, :date=>date, :who=>who, :msg=>msg, :commit_id=>id, :commit_date=>cdate)
91
91
  end
92
92
  list
93
93
  end
@@ -120,12 +120,10 @@ module Adapters
120
120
 
121
121
  # Create a tag for the given commit reference.
122
122
  def tag(ref, label, date, message)
123
- mfile = Tempfile.new("message")
124
- mfile.open{ |f| f << message }
123
+ file = tempfile("message", message)
124
+ date = date.strftime('%Y-%m-%d 23:59') unless String===date
125
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}]
126
+ cmd = %[GIT_AUTHOR_DATE='#{date}' GIT_COMMITTER_DATE='#{date}' git tag -a -F '#{file}' #{label} #{ref}]
129
127
  puts cmd if $DEBUG
130
128
  `#{cmd}` unless $DRYRUN
131
129
  end
@@ -9,19 +9,18 @@ module Adapters
9
9
  class Hg < Abstract
10
10
 
11
11
  # Collect changes.
12
- #
13
12
  def extract_changes
14
13
  list = []
15
14
  changelog = `hg log -v`.strip
16
15
  changes = changelog.split("\n\n\n")
17
16
  changes.each do |entry|
18
- list << parse_entry(entry)
17
+ id, date, who, msg = *parse_entry(entry)
18
+ list << Change.new(:id=>id, :date=>date, :who=>who, :msg=>msg)
19
19
  end
20
20
  list
21
21
  end
22
22
 
23
23
  # Collect tags.
24
- #
25
24
  def extract_tags
26
25
  list = []
27
26
  if File.exist?('.hgtags')
@@ -29,7 +28,7 @@ module Adapters
29
28
  rev, tag = line.strip.split(' ')
30
29
  entry = `hg log -v -r #{rev}`.strip
31
30
  rev, date, who, msg, type = parse_entry(entry)
32
- list << [tag, rev, date, who, msg]
31
+ list << Tag.new(:name=>tag, :id=>rev, :date=>date, :who=>who, :msg=>msg)
33
32
  end
34
33
  end
35
34
  list
@@ -57,12 +56,10 @@ module Adapters
57
56
 
58
57
  # TODO: Will multi-line messages work okay this way?
59
58
  def tag(ref, label, date, msg)
60
- mfile = Tempfile.new("message")
61
- mfile.open{ |f| f << msg }
62
-
59
+ file = tempfile("message", msg)
63
60
  date = date.strftime('%Y-%m-%d') unless String===date
64
61
 
65
- cmd = %[hg tag -r #{ref} -d #{date} -m "$(cat #{mfile.path})" #{label}]
62
+ cmd = %[hg tag -r #{ref} -d #{date} -m "$(cat #{file})" #{label}]
66
63
 
67
64
  puts cmd if $DEBUG
68
65
  `#{cmd}` unless $DRYRUN
@@ -21,7 +21,7 @@ module Adapters
21
21
  super(root)
22
22
  end
23
23
 
24
- #
24
+ # Extract changes.
25
25
  def extract_changes
26
26
  log = []
27
27
 
@@ -41,13 +41,13 @@ module Adapters
41
41
 
42
42
  date = Time.parse(date)
43
43
 
44
- log << [rev, date, who, msg]
44
+ log << Change.new(:id=>rev, :date=>date, :who=>who, :msg=>msg)
45
45
  end
46
46
 
47
47
  log
48
48
  end
49
49
 
50
- #
50
+ # Extract tags.
51
51
  def extract_tags
52
52
  list = []
53
53
  tagdir = tag_directory
@@ -78,7 +78,7 @@ module Adapters
78
78
  msg = [commit["msg"]].flatten.compact.join('').strip
79
79
  date = [commit["date"]].flatten.compact.join('').strip
80
80
 
81
- list << [name, rev, date, who, msg]
81
+ list << Tag.new(:name=>name, :id=>rev, :date=>date, :who=>who, :msg=>msg)
82
82
  end
83
83
  list
84
84
  end
@@ -127,10 +127,9 @@ module Adapters
127
127
  info['Repository UUID']
128
128
  end
129
129
 
130
- #
130
+ # TODO: Need to effect svn tag date. How?
131
131
  def tag(ref, label, date, message)
132
- mfile = Tempfile.new("message")
133
- mfile.open{ |f| f << message }
132
+ file = tempfile("message", message)
134
133
 
135
134
  Dir.chdir(root) do
136
135
  cmd = %[svn copy -r #{ref} -F "#{mfile.path}" . #{tag_directory}/#{label}]
@@ -2,15 +2,15 @@ require 'vclog/kernel'
2
2
 
3
3
  module VCLog
4
4
 
5
- # = Change Log Entry class
5
+ # The Change class models an extry in a change log.
6
6
  #
7
7
  class Change
8
8
 
9
9
  include Comparable
10
10
 
11
- attr_accessor :author
11
+ attr_accessor :id
12
12
  attr_accessor :date
13
- attr_accessor :revision
13
+ attr_accessor :author
14
14
  attr_accessor :message
15
15
 
16
16
  attr_accessor :type
@@ -18,14 +18,10 @@ module VCLog
18
18
  attr_accessor :label
19
19
 
20
20
  #
21
- def initialize(rev, date, author, message, type, level, label)
22
- self.revision = rev
23
- self.date = date
24
- self.author = author
25
- self.message = message
26
- self.type = type
27
- self.level = level
28
- self.label = label
21
+ def initialize(data={}) #rev, date, author, message, type, level, label
22
+ data.each do |k,v|
23
+ __send__("#{k}=", v)
24
+ end
29
25
  end
30
26
 
31
27
  #
@@ -33,9 +29,28 @@ module VCLog
33
29
  @author = author.strip
34
30
  end
35
31
 
36
- # Alternate name for revision.
37
- alias_method :rev, :revision
38
- alias_method :rev=, :revision=
32
+ #
33
+ def date=(date)
34
+ @date = parse_date(date)
35
+ end
36
+
37
+ # Alternate name for id.
38
+ alias_method :rev, :id
39
+ alias_method :rev=, :id=
40
+
41
+ # Alternate name for id.
42
+ alias_method :revision, :id
43
+ alias_method :revision=, :id=
44
+
45
+ # Alternate name for message.
46
+ alias_method :msg, :message
47
+ alias_method :msg=, :message=
48
+
49
+
50
+ # Alias for author.
51
+ alias_method :who, :author
52
+ alias_method :who=, :author=
53
+
39
54
 
40
55
  #def clean_type(type)
41
56
  # case type.to_s
@@ -94,6 +109,15 @@ module VCLog
94
109
  # to_h.to_yaml(*args)
95
110
  #end
96
111
 
112
+ def apply_heuristics(heuristics)
113
+ type, level, label, msg = *heuristics.lookup(message)
114
+
115
+ self.type = type
116
+ self.level = level
117
+ self.label = label
118
+ self.message = msg || @message
119
+ end
120
+
97
121
  =begin
98
122
  # Looks for a "[type]" indicator at the end of the commit message.
99
123
  # If that is not found, it looks at front of message for
@@ -118,6 +142,17 @@ module VCLog
118
142
  end
119
143
  =end
120
144
 
121
- end #class Entry
145
+ private
146
+
147
+ def parse_date(date)
148
+ case date
149
+ when Time
150
+ date
151
+ else
152
+ Time.parse(date.to_s)
153
+ end
154
+ end
155
+
156
+ end
122
157
 
123
158
  end
@@ -21,7 +21,8 @@ module CLI
21
21
  opt.separator(" ")
22
22
  opt.separator("SPECIAL OPTIONS:")
23
23
  opt.on('--prefix', '-p', 'tag label prefix'){ options[:prefix] = true }
24
- opt.on('--force', '-f', 'perform tagging without confirmation'){ options[:force] = true }
24
+ opt.on('--file' , '-f FILE', 'specify history file'){ options[:history_file] = file }
25
+ opt.on('--force' , '-y', 'perform tagging without confirmation'){ options[:force] = true }
25
26
  opt.on('--dryrun', '-n', 'run in dryrun mode'){ $DRYRUN = true }
26
27
  end
27
28
  end
@@ -71,9 +71,9 @@ module VCLog
71
71
 
72
72
  #ver = vcs.bump(version)
73
73
  user = vcs.user
74
- time = ::Time.now
74
+ time = ::Time.now + (3600 * 24) # one day ahead
75
75
 
76
- tags << Tag.new(nil, 'current', time, user, "Current Development")
76
+ tags << Tag.new(:name=>'HEAD', :id=>'HEAD', :date=>time, :who=>user, :msg=>"Current Development")
77
77
 
78
78
  # TODO: Do we need to add a Time.now tag?
79
79
  # add current verion to release list (if given)
@@ -91,8 +91,8 @@ module VCLog
91
91
  delta = []
92
92
  last = nil
93
93
  tags.each do |tag|
94
- delta << [tag, [last, tag.date]]
95
- last = tag.date
94
+ delta << [tag, [last, tag.commit_date]]
95
+ last = tag.commit_date
96
96
  end
97
97
  # gather changes for each delta
98
98
  delta.each do |tag, (started, ended)|
@@ -9,8 +9,8 @@ module VCLog
9
9
  FILE = '{HISTORY,HISTORY.*}'
10
10
 
11
11
  LINE = /^[=#]/
12
- VERS = /(\d+\.)+\d+/
13
- DATE = /(\d+\-)+\d+/
12
+ VERS = /(\d+[._])+\d+/
13
+ DATE = /(\d+[-])+\d+/
14
14
 
15
15
  #
16
16
  CASEFOLD = File::FNM_CASEFOLD
@@ -55,7 +55,7 @@ module VCLog
55
55
  index = desc.index(/^Changes:/) || desc.index(/^\*/) || desc.size
56
56
  desc = desc[0...index].strip.fold
57
57
  #[vers, date, desc]
58
- Tag.new(vers, nil, date, nil, desc)
58
+ Tag.new(:name=>vers, :date=>date, :msg=>desc)
59
59
  end
60
60
  end
61
61
 
@@ -1,6 +1,6 @@
1
1
  name : vclog
2
- date : 2010-11-19
3
- version : 1.8.0
2
+ date : 2010-11-22
3
+ version : 1.8.1
4
4
 
5
5
  requires:
6
6
  - facets 2.4+
@@ -97,7 +97,7 @@ module VCLog
97
97
 
98
98
  # Access to Repo's HISTORY file.
99
99
  def history_file
100
- @history_file ||= HistoryFile.new(root)
100
+ @history_file ||= HistoryFile.new(options[:history_file] || root)
101
101
  end
102
102
 
103
103
  # Read history file and make a commit tag for any release not already
@@ -1,19 +1,19 @@
1
1
  module VCLog
2
2
 
3
3
  class Tag
4
- attr_accessor :revision
5
4
  attr_accessor :name
6
5
  attr_accessor :date
7
6
  attr_accessor :author
8
7
  attr_accessor :message
9
8
 
9
+ attr_accessor :commit
10
+
10
11
  #
11
- def initialize(name, rev, date, author, message)
12
- self.name = name
13
- self.revision = rev
14
- self.date = date
15
- self.author = author
16
- self.message = message
12
+ def initialize(data={})
13
+ @commit = Change.new
14
+ data.each do |k,v|
15
+ __send__("#{k}=", v)
16
+ end
17
17
  end
18
18
 
19
19
  #
@@ -22,21 +22,27 @@ module VCLog
22
22
  end
23
23
 
24
24
  #
25
- alias_method :label, :name
25
+ alias_method :label, :name
26
+ alias_method :label=, :name=
27
+
28
+ #
29
+ alias_method :tag, :name
30
+ alias_method :tag=, :name=
26
31
 
27
32
  #
28
33
  def author=(author)
29
34
  @author = author.to_s.strip
30
35
  end
31
36
 
37
+ alias_method :tagger, :author
38
+ alias_method :tagger=, :author=
39
+
40
+ alias_method :who, :author
41
+ alias_method :who=, :author=
42
+
32
43
  #
33
44
  def date=(date)
34
- case date
35
- when Time
36
- @date = date
37
- else
38
- @date = Time.parse(date.to_s)
39
- end
45
+ @date = parse_date(date)
40
46
  end
41
47
 
42
48
  #
@@ -44,8 +50,37 @@ module VCLog
44
50
  @message = msg.strip
45
51
  end
46
52
 
47
- alias_method :tagger, :author
48
- alias_method :tagger=, :author=
53
+ alias_method :msg, :message
54
+ alias_method :msg=, :message=
55
+
56
+
57
+ #
58
+ def commit_id
59
+ @commit.id
60
+ end
61
+
62
+ #
63
+ def commit_id=(id)
64
+ @commit.id = id
65
+ end
66
+
67
+ #
68
+ alias_method :id, :commit_id
69
+ alias_method :id=, :commit_id=
70
+
71
+ #
72
+ alias_method :revision, :commit_id
73
+ alias_method :revision=, :commit_id=
74
+
75
+ #
76
+ def commit_date
77
+ @commit.date ||= date
78
+ end
79
+
80
+ #
81
+ def commit_date=(date)
82
+ @commit.date = date
83
+ end
49
84
 
50
85
  #
51
86
  def to_json
@@ -72,6 +107,18 @@ module VCLog
72
107
  return -1 if name == 'HEAD'
73
108
  other.name <=> name
74
109
  end
110
+
111
+ private
112
+
113
+ def parse_date(date)
114
+ case date
115
+ when Time
116
+ date
117
+ else
118
+ Time.parse(date.to_s)
119
+ end
120
+ end
121
+
75
122
  end
76
123
 
77
124
  end
@@ -8,7 +8,12 @@ history.releases.sort.each do |release|
8
8
 
9
9
  tag = release.tag
10
10
 
11
- out << "\n#{tag.name} / #{tag.date.strftime('%Y-%m-%d')}".ansi(:bold)
11
+ # TODO: support verbose option
12
+ #if verbose?
13
+ # out << "\n#{tag.name} / #{tag.date.strftime('%Y-%m-%d %H:%M')}".ansi(:bold)
14
+ #else
15
+ out << "\n#{tag.name} / #{tag.date.strftime('%Y-%m-%d')}".ansi(:bold)
16
+ #end
12
17
 
13
18
  out << "\n#{tag.message.strip} (#{tag.author})"
14
19
 
@@ -15,7 +15,13 @@ Ensure all HISTORY file entries have corresponding commit tags in the version co
15
15
  .SH "OPTIONS"
16
16
  .
17
17
  .IP "\(bu" 4
18
- \fB\-\-force\fR, \fB\-f\fR Creatie tags without asking for confirmation\.
18
+ \fB\-\-force\fR, \fB\-y\fR Create tags without asking for confirmation\.
19
+ .
20
+ .IP "\(bu" 4
21
+ \fB\-\-prefix\fR, \fB\-p PREFIX\fR Specify a prefix to add to version tags\. Typically this will be the letter \'v\'\.
22
+ .
23
+ .IP "\(bu" 4
24
+ \fB\-\-file\fR, \fB\-f FILE\fR Specify a specific history file to use\. This is useful is the history file does not conform to the usual naming convention of \fBHISTORY\.*\fR\.
19
25
  .
20
26
  .IP "" 0
21
27
  .
@@ -1,6 +1,6 @@
1
1
  name : vclog
2
- date : 2010-11-19
3
- version : 1.8.0
2
+ date : 2010-11-22
3
+ version : 1.8.1
4
4
 
5
5
  requires:
6
6
  - facets 2.4+
@@ -12,8 +12,17 @@ the version control system.
12
12
 
13
13
  ## OPTIONS
14
14
 
15
- * `--force`, `-f`
16
- Creatie tags without asking for confirmation.
15
+ * `--force`, `-y`
16
+ Create tags without asking for confirmation.
17
+
18
+ * `--prefix`, `-p PREFIX`
19
+ Specify a prefix to add to version tags. Typically
20
+ this will be the letter 'v'.
21
+
22
+ * `--file`, `-f FILE`
23
+ Specify a specific history file to use. This is useful
24
+ is the history file does not conform to the usual naming
25
+ convention of `HISTORY.*`.
17
26
 
18
27
  ## SEE ALSO
19
28
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vclog
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 53
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 8
9
- - 0
10
- version: 1.8.0
9
+ - 1
10
+ version: 1.8.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Sawyer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-20 00:00:00 -05:00
18
+ date: 2010-11-21 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency