Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Re-add the longest prefix feature for github.

Add a test case for that.  Update the novemberlog test case too (it was
still feeding in the old-style xml stuff).
  • Loading branch information...
commit db6f4b0164535817d7e00b2da4beb1a1417b1506 1 parent 0d04cb5
Infinoid authored
30 modules/local/githubparser.pm
@@ -216,8 +216,10 @@ sub try_link {
216 216 if(!defined($self)) {
217 217 $objects_by_package{$modulename} = $self = {
218 218 project => $project,
  219 + author => $author,
219 220 modulename => $modulename,
220 221 branches => {},
  222 + commit => "http://github.com/api/v2/yaml/commits/show/$author/$project/",
221 223 };
222 224
223 225 # create a dynamic subclass to get the timer callback back to us
@@ -290,12 +292,26 @@ sub output_item {
290 292 pop(@lines) if $lines[-1] =~ /^git-svn-id: http:/;
291 293 pop(@lines) while scalar(@lines) && $lines[-1] eq '';
292 294
293   -# $prefix = "";
294   -# $prefix //= '/';
295   -# $prefix =~ s|^/||; # cut off the leading slash
296   -# if(scalar @files > 1) {
297   -# $prefix .= " (" . scalar(@files) . " files)";
298   -# }
  295 + my @files;
  296 + my $commit = $$self{commit} . $rev;
  297 + $commit = get_yaml($commit);
  298 + if(defined($commit)) {
  299 + $commit = $$commit{commit};
  300 + @files = map { $$_{filename} } (@{$$commit{modified}});
  301 + @files = (@files, @{$$commit{added}}) if exists $$commit{added};
  302 + @files = (@files, @{$$commit{removed}}) if exists $$commit{removed};
  303 + $prefix = longest_common_prefix(@files);
  304 + if(defined($prefix) && length($prefix)) {
  305 + # cut off the leading slash.
  306 + $prefix =~ s|^/||;
  307 + } else {
  308 + # add a leading slash, just to be different.
  309 + $prefix = '/' unless(defined($prefix) && length($prefix));
  310 + }
  311 + if(scalar @files > 1) {
  312 + $prefix .= " (" . scalar(@files) . " files)";
  313 + }
  314 + }
299 315
300 316 $rev = substr($rev, 0, 7);
301 317
@@ -310,7 +326,7 @@ sub output_item {
310 326 user => $creator,
311 327 log => \@lines,
312 328 link => $link,
313   -# prefix => $prefix,
  329 + prefix => $prefix,
314 330 targets => $$self{branches}{$branch}{targets},
315 331 );
316 332
165 t/novemberlog.t
@@ -14,33 +14,33 @@ BEGIN { $tests = 0; };
14 14
15 15 plan tests => $tests;
16 16
17   -my $xml_header = << '__XML__';
18   -<?xml version="1.0" encoding="UTF-8"?>
19   -<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
20   - <id>tag:github.com,2008:/feeds/viklund/commits/november/master</id>
21   - <link type="text/html" rel="alternate" href="http://github.com/viklund/november/commits/master/"/>
22   - <link type="application/atom+xml" rel="self" href="http://github.com/feeds/viklund/commits/november/master"/>
23   - <title>Recent Commits to november:master</title>
24   -__XML__
  17 +my $yaml_header = << '__YAML__';
  18 +---
  19 +commits:
  20 +__YAML__
25 21
26   -my $xml_footer = << '__XML__';
27   - <entry>
28   - <id>tag:github.com,2008:Grit::Commit/c7d2d7784f80b2c9f05b68d4aa5a6e21a2f2a257</id>
29   - <link type="text/html" rel="alternate" href="http://github.com/viklund/november/commit/c7d2d7784f80b2c9f05b68d4aa5a6e21a2f2a257"/>
30   - <title>Merge branch 'master' of git@github.com:viklund/november</title>
31   - <updated>2009-05-01T09:32:55-07:00</updated>
32   - <content type="html">&lt;pre&gt;
33   -Merge branch 'master' of git@github.com:viklund/novemberlt;/pre&gt;</content>
34   - <author>
35   - <name>pmichaud</name>
36   - </author>
37   - </entry>
38   -</feed>
39   -__XML__
  22 +my $yaml_footer = << '__YAML__';
  23 +- parents:
  24 + - id: da4527eb728cf268cfcdbb772b2c781458c49994
  25 + author:
  26 + name: Carl Masak
  27 + login: masak
  28 + email: cmasak@gmail.com
  29 + url: http://github.com/viklund/november/commit/78805c2e9337d2d72a28b11e632b37cd31feeb8c
  30 + id: 78805c2e9337d2d72a28b11e632b37cd31feeb8c
  31 + committed_date: "2009-11-01T12:57:46-08:00"
  32 + authored_date: "2009-11-01T12:57:46-08:00"
  33 + message: "[08-formatting-and-links.t] fixed bitrot"
  34 + tree: 93b789bdadc6dc60119959806422481e8701b4fb
  35 + committer:
  36 + name: Carl Masak
  37 + login: masak
  38 + email: cmasak@gmail.com
  39 +__YAML__
40 40
41 41 # initial sync
42   -my $xml = $xml_header . '<updated>2009-05-01T09:32:55-07:00</updated>' . $xml_footer;
43   -my $feed = XML::Atom::Feed->new(\$xml);
  42 +my $yaml = $yaml_header . $yaml_footer;
  43 +my $feed = YAML::Syck::Load($yaml);
44 44 my $rl = modules::local::novemberlog->get_self();
45 45 ok(!exists($$rl{lastrev}), "no lastrev by default");
46 46 call_func('process_branch', 'master', $feed);
@@ -52,28 +52,26 @@ BEGIN { $tests += 3 };
52 52 # update
53 53 reset_output();
54 54 $$rl{not_first_time} = 1;
55   -$xml_footer = << '__XML__' . $xml_footer;
56   - <entry>
57   - <id>tag:github.com,2008:Grit::Commit/7f5af50c19baf360dacc5779b9c013fb14db34d3</id>
58   - <link type="text/html" rel="alternate" href="http://github.com/viklund/november/commit/7f5af50c19baf360dacc5779b9c013fb14db34d3"/>
59   - <title>Big refactor of Rakudo's enums, making them more compliant with S12, and building them with much less generated code. Track an enum related grammar change from STD.pm too. Also gets rid of various bits of cruft that only hung around because of the previous enums implementation needing them. Bool is no longer sort-of-enum-ish (before we had some curious interactions there). Also an infinite loop in infix:&lt;but&gt; is fixed.</title>
60   - <updated>2009-05-01T09:58:40-07:00</updated>
61   - <content type="html">&lt;pre&gt;m src/builtins/enums.pir
62   -m src/builtins/guts.pir
63   -m src/builtins/op.pir
64   -m src/classes/Abstraction.pir
65   -m src/classes/Bool.pir
66   -m src/parser/actions.pm
67   -m src/parser/grammar.pg
68   -
69   -Big refactor of Rakudo's enums, making them more compliant with S12, and building them with much less generated code. Track an enum related grammar change from STD.pm too. Also gets rid of various bits of cruft that only hung around because of the previous enums implementation needing them. Bool is no longer sort-of-enum-ish (before we had some curious interactions there). Also an infinite loop in infix:&amp;lt;but&amp;gt; is fixed.&lt;/pre&gt;</content>
70   - <author>
71   - <name>jnthn</name>
72   - </author>
73   - </entry>
74   -__XML__
75   -$xml = $xml_header . '<updated>2009-05-01T09:58:40-07:00</updated>' . $xml_footer;
76   -$feed = XML::Atom::Feed->new(\$xml);
  55 +$yaml_footer = << '__YAML__' . $yaml_footer;
  56 +- parents:
  57 + - id: 6d57c895b86859b5c2c7305d21d3b6ad0dd6bde2
  58 + author:
  59 + name: Carl Masak
  60 + login: masak
  61 + email: cmasak@gmail.com
  62 + url: http://github.com/viklund/november/commit/4e56a149a03c010a31d279d4bba93bf
  63 + id: 4e56a149a03c010a31d279d4bba93bf3b9ca74fe
  64 + committed_date: "2010-05-05T07:10:11-07:00"
  65 + authored_date: "2010-05-05T07:10:11-07:00"
  66 + message: "[docs/blog-posts.md] fixed copy-paste-o"
  67 + tree: 314e6df17f751c1811b2548a383a7cef5c596b93
  68 + committer:
  69 + name: Carl Masak
  70 + login: masak
  71 + email: cmasak@gmail.com
  72 +__YAML__
  73 +$yaml = $yaml_header . $yaml_footer;
  74 +$feed = YAML::Syck::Load($yaml);
77 75 call_func('process_branch', 'master', $feed);
78 76 $output = [output()];
79 77 is(scalar @$output, 6, "6 lines of output");
@@ -85,44 +83,59 @@ BEGIN { $tests += 5 };
85 83
86 84 # update with multiple commits having the same timestamp
87 85 reset_output();
88   -$xml_footer = << '__XML__' . $xml_footer;
89   - <entry>
90   - <id>tag:github.com,2008:Grit::Commit/5bd02be9924c2f6013e4601e55d103b1e1a30a14</id>
91   - <link type="text/html" rel="alternate" href="http://github.com/viklund/november/commit/5bd02be9924c2f6013e4601e55d103b1e1a30a14"/>
92   - <title>Small optimizations to signature binding; costs us a PMC creation and a method call less every invocation of something that has a signature, which gives a 7% speed-up in a calling benchmark.</title>
93   - <updated>2009-05-15T06:45:18-07:00</updated>
94   - <content type="html">&lt;pre&gt;m src/classes/Signature.pir
  86 +$yaml_footer = << '__YAML__' . $yaml_footer;
  87 +- parents:
  88 + - id: c5fd6a474718a4e7a986db3216c7ea63ecd12387
  89 + author:
  90 + name: Carl Masak
  91 + login: masak
  92 + email: cmasak@gmail.com
  93 + url: http://github.com/viklund/november/commit/6d57c895b86859b5c2c7305d21d3b6a
  94 + id: 6d57c895b86859b5c2c7305d21d3b6ad0dd6bde2
  95 + committed_date: "2010-05-05T07:05:17-07:00"
  96 + authored_date: "2010-05-05T07:05:17-07:00"
  97 + message: |-
  98 + [docs/blog-posts.md] links to all known posts
95 99
96   -Small optimizations to signature binding; costs us a PMC creation and a method call less every invocation of something that has a signature, which gives a 7% speed-up in a calling benchmark.&lt;/pre&gt;</content>
97   - <author>
98   - <name>jnthn</name>
99   - </author>
100   - </entry>
101   - <entry>
102   - <id>tag:github.com,2008:Grit::Commit/b49cce1a84c1f229d1c542c2dc2556e2912aa960</id>
103   - <link type="text/html" rel="alternate" href="http://github.com/viklund/november/commit/b49cce1a84c1f229d1c542c2dc2556e2912aa960"/>
104   - <title>Add some micro-benchmakrs.</title>
105   - <updated>2009-05-15T06:45:18-07:00</updated>
106   - <content type="html">&lt;pre&gt;+ tools/benchmark.pl
  100 + ...about November. Tried to find them all in my feed; might have missed seme
  101 + Definitely missed some from other people. Feel free to supplement.
  102 + tree: ecaf0815787f742fa9976883c7a40d4b7f744a73
  103 + committer:
  104 + name: Carl Masak
  105 + login: masak
  106 + email: cmasak@gmail.com
  107 +- parents:
  108 + - id: 95134d49a4d5e168ad17244bbcfd9927cf684cf4
  109 + author:
  110 + name: Carl Masak
  111 + login: masak
  112 + email: cmasak@gmail.com
  113 + url: http://github.com/viklund/november/commit/c5fd6a474718a4e7a986db3216c7ea6
  114 + id: c5fd6a474718a4e7a986db3216c7ea63ecd12387
  115 + committed_date: "2010-05-05T07:05:17-07:00"
  116 + authored_date: "2010-05-05T07:05:17-07:00"
  117 + message: |-
  118 + [Makefile] added to version control
107 119
108   -Add some micro-benchmakrs.&lt;/pre&gt;</content>
109   - <author>
110   - <name>jnthn</name>
111   - </author>
112   - </entry>
113   -__XML__
114   -$xml = $xml_header . '<updated>2009-05-15T06:45:18-07:00</updated>' . $xml_footer;
115   -$feed = XML::Atom::Feed->new(\$xml);
  120 + It assumes an installed 'perl6', as opposed to the old one.
  121 + tree: aa0438d1b6ede0bcea2cfeb4880e5ddd512697bf
  122 + committer:
  123 + name: Carl Masak
  124 + login: masak
  125 + email: cmasak@gmail.com
  126 +__YAML__
  127 +$yaml = $yaml_header . $yaml_footer;
  128 +$feed = YAML::Syck::Load($yaml);
116 129 call_func('process_branch', 'master', $feed);
117 130 $output = [output()];
118   -is(scalar @$output, 12, "12 lines of output");
  131 +is(scalar @$output, 22, "22 lines of output");
119 132 is($$output[0]{net} , 'freenode', "line to freenode/#november-wiki");
120 133 is($$output[0]{chan}, '#november-wiki' , "line to freenode/#november-wiki");
121 134 is($$output[1]{net} , 'freenode', "line to freenode/#perl6");
122 135 is($$output[1]{chan}, '#perl6' , "line to freenode/#perl6");
123 136 # The module sorts by <updated> time, but the time is the same for these two commits.
124 137 # Do it this way so we don't depend on perl's internal sort algorithm details.
125   -my @message_list = ($$output[2]{text}, $$output[8]{text});
126   -is(scalar grep(/Small optimizations/ , @message_list), 1, "log message");
127   -is(scalar grep(/Add some micro-bench/, @message_list), 1, "log message");
  138 +my @message_list = ($$output[6]{text}, $$output[14]{text});
  139 +is(scalar grep(/Tried to find them/ , @message_list), 1, "log message");
  140 +is(scalar grep(/added to version/, @message_list), 1, "log message");
128 141 BEGIN { $tests += 7 };
3  t/rakudolog.t
@@ -81,7 +81,8 @@ is(scalar @$output, 6, "6 lines of output");
81 81 is($$output[0]{net} , 'magnet' , "line to magnet/#parrot");
82 82 is($$output[0]{chan}, '#parrot' , "line to magnet/#parrot");
83 83 like($$output[0]{text}, qr|rakudo: |, "master branch");
  84 +like($$output[0]{text}, qr|t/spectest\.data|, "changed file is listed");
84 85 is($$output[1]{net} , 'freenode', "line to freenode/#perl6");
85 86 is($$output[1]{chan}, '#perl6' , "line to freenode/#perl6");
86 87 like($$output[1]{text}, qr|rakudo: |, "master branch");
87   -BEGIN { $tests += 7 };
  88 +BEGIN { $tests += 8 };

0 comments on commit db6f4b0

Please sign in to comment.
Something went wrong with that request. Please try again.