blastr 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  == 0.0.13 2009-02-20
2
2
 
3
+ * Added support for multi-line comments in Mercurial.
4
+
5
+ == 0.0.13 2009-02-20
6
+
3
7
  * Added support for multi-line comments in SVN.
4
8
 
5
9
  == 0.0.12 2009-01-19
@@ -19,6 +19,7 @@ test/test_blastr.rb
19
19
  test/test_git_log_entry.rb
20
20
  test/test_git_revision.rb
21
21
  test/test_helper.rb
22
+ test/test_mercurial_log.rb
22
23
  test/test_mercurial_revision.rb
23
24
  test/test_scm_logentry.rb
24
25
  test/test_scm_url_matching.rb
@@ -12,7 +12,7 @@ systems as well.
12
12
 
13
13
  === FEATURES:
14
14
 
15
- Blastr can observe a single "branch" (identified by a URL) by polling the
15
+ Blastr can observe a "branch" (identified by a URL) by polling the
16
16
  repository for a commit log. Any new commits will be announced. When
17
17
  starting Blastr, it can be told to start observing from a given revision
18
18
  or let it figure out the latest revision and start from that.
@@ -88,7 +88,7 @@ your platform.
88
88
  Blastr's behavior when encountering weird Norwegian scribble.
89
89
  * Some folks might want to monitor multiple repositories or multiple
90
90
  paths or branches within a repository at the same time. Currently,
91
- this is technically possible by running to instances of Blastr in
91
+ this is technically possible by running two instances of Blastr in
92
92
  parallel but every now and then those two instances will speak over
93
93
  each other (i.e. all you can hear is cacophony).
94
94
 
@@ -6,7 +6,7 @@ module Blastr
6
6
  require 'tts/tts.rb'
7
7
  require 'people/people.rb'
8
8
 
9
- VERSION = '0.0.13'
9
+ VERSION = '0.0.14'
10
10
  COPYRIGHT = 'Copyright (c) 2009, Lasse Koskela. All Rights Reserved.'
11
11
  puts "Blastr #{VERSION}\n#{COPYRIGHT}\n"
12
12
 
@@ -14,6 +14,10 @@ module Blastr::SourceControl
14
14
  @name
15
15
  end
16
16
 
17
+ def ==(other)
18
+ @name == other.name
19
+ end
20
+
17
21
  def before?(revision)
18
22
  return false if @name == "tip"
19
23
  return true if revision.name == "tip"
@@ -49,28 +53,24 @@ module Blastr::SourceControl
49
53
  end
50
54
  end
51
55
 
52
- private
53
- def hg_log(revision = 0)
56
+ def hg_log_entries(output)
54
57
  nonascii = /([^a-zA-Z0-9\.,:;\-_\?!"'\s]+?)/u
55
58
  entries = []
56
59
  current_changeset = {}
57
- %x[hg log -r #{revision}:].each_line do |line|
58
- if line =~ /^changeset:\s+(.+?):(.+?)$/
59
- entries << current_changeset unless current_changeset.empty?
60
- current_changeset = { :revision => $1, :hash => $2 }
61
- elsif line =~ /^user:\s+(.+?)(\s<(.+?)@(.+?)>)?$/
62
- current_changeset[:author] = $1
63
- elsif line =~ /^summary:\s+(.+?)$/
64
- current_changeset[:comment] = $1.strip
65
- elsif current_changeset.key? :comment
66
- current_changeset[:comment] = "#{current_changeset[:comment]} #{line.strip}"
60
+ output.split(/-{69,71}/).each do |entry|
61
+ if entry =~ /^changeset (\d+):(.+) by (.+):\n(.*)/mu
62
+ entries << LogEntry.new(as_revision($1), $3, $4.strip)
67
63
  end
68
64
  end
69
- entries << current_changeset unless current_changeset.empty?
70
-
71
- entries.collect do |map|
72
- LogEntry.new(as_revision(map[:revision]), map[:author], map[:comment].gsub(nonascii, 'X '))
73
- end
65
+ entries
66
+ end
67
+
68
+ private
69
+ def hg_log(revision = 0)
70
+ separator = "-" * 70
71
+ template = "\\nchangeset {rev}:{node} by {author}:\\n{desc}\\n#{separator}"
72
+ output = %x[hg log -r '#{revision}:' --template '#{template}'].strip
73
+ hg_log_entries(output)
74
74
  end
75
75
 
76
76
  private
@@ -0,0 +1,74 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestMercurialLogParsing < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @hg = Blastr::SourceControl::Mercurial.new("hg:http://whatever")
7
+ end
8
+
9
+ def test_one_entry
10
+ log = <<EOS
11
+ changeset 24:e8a2a4d187773a62f3309b0fa265c13425bc2258 by username:
12
+ This is the commit message
13
+ ----------------------------------------------------------------------
14
+ EOS
15
+ entries = @hg.hg_log_entries(log)
16
+ assert_equal [ create_entry("24", "username", "This is the commit message") ], entries
17
+ end
18
+
19
+ def test_multiple_entries
20
+ log = <<EOS
21
+ changeset 10:e8a2a4d187773a62f3309b0fa265c13425bc2258 by alf:
22
+ Revision 10
23
+ ----------------------------------------------------------------------
24
+ changeset 9:d7744e86dedc21a8ecf6bdb73eb191b8eaf5b0da by bob:
25
+ Revision 9
26
+ ----------------------------------------------------------------------
27
+ changeset 8:4ae9f4bfdb98f65bd957e3fe72471b320150b38e by alf:
28
+ Revision 8
29
+ ----------------------------------------------------------------------
30
+ EOS
31
+ entries = @hg.hg_log_entries(log)
32
+ assert_equal [ create_entry("10", "alf", "Revision 10"),
33
+ create_entry("9", "bob", "Revision 9"),
34
+ create_entry("8", "alf", "Revision 8") ], entries
35
+ end
36
+
37
+ def test_one_multiline_entry_with_dashes_in_the_commit_message
38
+ log = <<EOS
39
+ changeset 123:e8a2a4d187773a62f3309b0fa265c13425bc2258 by ohair:
40
+ ---
41
+ -----
42
+ -
43
+ - Bullet
44
+ ----------------------------------------------------------------------
45
+ EOS
46
+ entries = @hg.hg_log_entries(log)
47
+ assert_equal [ create_entry("123", "ohair", "---\n-----\n-\n- Bullet") ], entries
48
+ end
49
+
50
+
51
+ def test_multiple_multiline_entries_with_empty_lines_within_commit_message
52
+ log = <<EOS
53
+ changeset 2:e8a2a4d187773a62f3309b0fa265c13425bc2258 by cat:
54
+ --
55
+ ----------------------------------------------------------------------
56
+ changeset 1:d7744e86dedc21a8ecf6bdb73eb191b8eaf5b0da by bob:
57
+ -
58
+ ----------------------------------------------------------------------
59
+ changeset 0:4ae9f4bfdb98f65bd957e3fe72471b320150b38e by alf:
60
+
61
+ ----------------------------------------------------------------------
62
+ EOS
63
+ entries = @hg.hg_log_entries(log)
64
+ assert_equal [ create_entry("2", "cat", "--"),
65
+ create_entry("1", "bob", "-"),
66
+ create_entry("0", "alf", "") ], entries
67
+ end
68
+
69
+ private
70
+ def create_entry(rev_string, author, comment)
71
+ revision = Blastr::SourceControl::MercurialRevision.new(rev_string)
72
+ Blastr::SourceControl::LogEntry.new(revision, author, comment)
73
+ end
74
+ end
@@ -3,21 +3,30 @@ require File.dirname(__FILE__) + '/test_helper.rb'
3
3
  class TestMercurialRevision < Test::Unit::TestCase
4
4
 
5
5
  def test_to_s
6
- rev = Blastr::SourceControl::MercurialRevision.new("123")
7
- assert rev.to_s == "123"
6
+ assert revision("123").to_s == "123"
7
+ end
8
+
9
+ def test_equality_comparison
10
+ assert_equal revision("123"), revision("123")
11
+ assert revision("456") == revision("456")
8
12
  end
9
13
 
10
14
  def test_before_comparison_between_revisions
11
- rev123 = Blastr::SourceControl::MercurialRevision.new("123")
12
- rev456 = Blastr::SourceControl::MercurialRevision.new("456")
15
+ rev123 = revision("123")
16
+ rev456 = revision("456")
13
17
  assert rev123.before?(rev456) == true
14
18
  assert rev456.before?(rev123) == false
15
19
  end
16
20
 
17
21
  def test_before_comparison_with_tip
18
- rev = Blastr::SourceControl::MercurialRevision.new("100")
19
- tip = Blastr::SourceControl::MercurialRevision.new("tip")
22
+ rev = revision("100")
23
+ tip = revision("tip")
20
24
  assert rev.before?(tip) == true
21
25
  assert tip.before?(rev) == false
22
26
  end
27
+
28
+ private
29
+ def revision(value)
30
+ Blastr::SourceControl::MercurialRevision.new(value)
31
+ end
23
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blastr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lasse Koskela
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-20 00:00:00 +02:00
12
+ date: 2009-02-21 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,7 @@ files:
66
66
  - test/test_git_log_entry.rb
67
67
  - test/test_git_revision.rb
68
68
  - test/test_helper.rb
69
+ - test/test_mercurial_log.rb
69
70
  - test/test_mercurial_revision.rb
70
71
  - test/test_scm_logentry.rb
71
72
  - test/test_scm_url_matching.rb
@@ -105,6 +106,7 @@ test_files:
105
106
  - test/test_git_log_entry.rb
106
107
  - test/test_git_revision.rb
107
108
  - test/test_helper.rb
109
+ - test/test_mercurial_log.rb
108
110
  - test/test_mercurial_revision.rb
109
111
  - test/test_scm_logentry.rb
110
112
  - test/test_scm_url_matching.rb