[Bps-public-commit] App-Changeloggr branch, master, updated. a993dbdcd647c62070be557dec7e178ec6ec1fec
sartak at bestpractical.com
sartak at bestpractical.com
Thu Mar 26 19:37:29 EDT 2009
The branch, master has been updated
via a993dbdcd647c62070be557dec7e178ec6ec1fec (commit)
from c2eeb00886b457a4249e0253068192d91e28dfe5 (commit)
Summary of changes:
lib/App/Changeloggr/Model/ChangeCollection.pm | 122 ++++++++++++++++++++++++
lib/App/Changeloggr/Model/Changelog.pm | 2 +-
lib/App/Changeloggr/Model/ChangesCollection.pm | 72 --------------
3 files changed, 123 insertions(+), 73 deletions(-)
create mode 100644 lib/App/Changeloggr/Model/ChangeCollection.pm
delete mode 100644 lib/App/Changeloggr/Model/ChangesCollection.pm
- Log -----------------------------------------------------------------
commit a993dbdcd647c62070be557dec7e178ec6ec1fec
Author: Shawn M Moore <sartak at gmail.com>
Date: Thu Mar 26 19:37:12 2009 -0400
Move ChangesCollection to ChangeCollection
diff --git a/lib/App/Changeloggr/Model/ChangeCollection.pm b/lib/App/Changeloggr/Model/ChangeCollection.pm
new file mode 100644
index 0000000..5cfff4a
--- /dev/null
+++ b/lib/App/Changeloggr/Model/ChangeCollection.pm
@@ -0,0 +1,122 @@
+package App::Changeloggr::Model::ChangeCollection;
+use strict;
+use warnings;
+use base 'App::Changeloggr::Collection';
+use Params::Validate 'SCALAR';
+
+sub create_from_text {
+ my $self = shift;
+ my %args = validate(@_, {
+ text => { type => SCALAR },
+ changelog => { isa => 'App::Changeloggr::Model::Changelog' },
+ });
+
+ my $text = $args{text};
+ my $changelog = $args{changelog};
+
+ while (length $text) {
+ my ($fields, $newtext) = $self->extract_change_data_from_text($text);
+ last if !defined($newtext);
+
+ my $change = App::Changeloggr::Model::Change->new;
+ $change->create(
+ %$fields,
+ changelog => $changelog,
+ );
+ $self->add_record($change);
+
+ $text = $newtext;
+ }
+
+ return $text;
+}
+
+sub extract_change_data_from_text {
+ my $self = shift;
+ my $text = shift;
+
+ my $format = App::Changeloggr->identify_format($text);
+ die "I'm unable to handle the change text format."
+ if !defined($format);
+
+ my $extract_method = "extract_change_data_from_$format";
+ return $self->$extract_method($text);
+}
+
+sub extract_change_data_from_git {
+ my $self = shift;
+ my $text = shift;
+
+ # git log --format=fuller --stat
+ $text =~ s{
+ \A
+ (
+ ^ commit \ \w+ $
+ .*?
+ )
+ (?=
+ \Z
+ |
+ ^ commit \ \w+ $
+ )
+ }{}xms;
+
+ my $entry = $1
+ or return;
+ my %fields;
+
+ return (\%fields, $text);
+}
+
+=begin git-sample
+
+(this is produced by git log --format=fuller --stat)
+
+commit 8837a66df7e8959d3101a5227d7b3c597990c0d0
+Author: Nicholas Clark <nick at ccl4.org>
+AuthorDate: Tue Dec 2 20:16:33 2008 +0000
+Commit: David Mitchell <davem at iabyn.com>
+CommitDate: Wed Jan 28 00:05:55 2009 +0000
+
+ Codify the current behaviour of evals which define subroutines before
+ failing (due to syntax errors).
+
+ p4raw-id: //depot/perl at 34984
+
+ (cherry picked from commit 99d3381e871dbd1d94b47516b4475d85b3935ac6)
+
+ t/comp/retainedlines.t | 23 ++++++++++++++++++++++-
+ 1 files changed, 22 insertions(+), 1 deletions(-)
+
+=cut
+
+sub hashify_git_stanza {
+ my @lines = (@_);
+ my $content = join('', at lines);
+ my $stanza = {};
+ if ($content =~ /^commit (.*)$/im) {
+ $stanza->{commit_id} = $1;
+ }
+ if ($content =~ /^Author:\s*(.*)$/im) {
+ $stanza->{author} = $1;
+ }
+ if ($content =~ /^(?:Author)?Date:\s*(.*)$/im) {
+ $stanza->{date} = $1;
+ }
+ if ($content =~ /^Commit:\s*(.*)$/im) {
+ $stanza->{commit} = $1;
+ }
+ if ($content =~ /^CommitDate:\s*(.*)$/im) {
+ $stanza->{commit_date} = $1;
+ }
+
+ if ($content =~ /.*?^(\s{4}.*?)(^\s{1,2}\S+\s+\|\s+\d+|\z)/ims) {
+ $stanza->{msg} = $1;
+ }
+ if ($content =~ /\n(\s{1,2}\S+\s+\|\s+\d+.*)$/ims) {
+ $stanza->{changed_files} = $1;
+ }
+ return $stanza;
+
+1;
+
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index 7e9e3a3..e14a2fb 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -43,7 +43,7 @@ sub parse_and_add_changes {
my $self = shift;
my $text = shift;
- my $changes = App::Changeloggr::Model::ChangesCollection->new;
+ my $changes = App::Changeloggr::Model::ChangeCollection->new;
$changes->create_from_text(
text => $text,
changelog => $self,
diff --git a/lib/App/Changeloggr/Model/ChangesCollection.pm b/lib/App/Changeloggr/Model/ChangesCollection.pm
deleted file mode 100644
index 73295dd..0000000
--- a/lib/App/Changeloggr/Model/ChangesCollection.pm
+++ /dev/null
@@ -1,72 +0,0 @@
-package App::Changeloggr::Model::ChangesCollection;
-use strict;
-use warnings;
-use base 'App::Changeloggr::Collection';
-use Params::Validate 'SCALAR';
-
-sub create_from_text {
- my $self = shift;
- my %args = validate(@_, {
- text => { type => SCALAR },
- changelog => { isa => 'App::Changeloggr::Model::Changelog' },
- });
-
- my $text = $args{text};
- my $changelog = $args{changelog};
-
- while (length $text) {
- my ($fields, $newtext) = $self->extract_change_data_from_text($text);
- last if !defined($newtext);
-
- my $change = App::Changeloggr::Model::Change->new;
- $change->create(
- %$fields,
- changelog => $changelog,
- );
- $self->add_record($change);
-
- $text = $newtext;
- }
-
- return $text;
-}
-
-sub extract_change_data_from_text {
- my $self = shift;
- my $text = shift;
-
- my $format = App::Changeloggr->identify_format($text);
- die "I'm unable to handle the change text format."
- if !defined($format);
-
- my $extract_method = "extract_change_data_from_$format";
- return $self->$extract_method($text);
-}
-
-sub extract_change_data_from_git {
- my $self = shift;
- my $text = shift;
-
- # git log --format=fuller --stat
- $text =~ s{
- \A
- (
- ^ commit \ \w+ $
- .*?
- )
- (?=
- \Z
- |
- ^ commit \ \w+ $
- )
- }{}xms;
-
- my $entry = $1
- or return;
- my %fields;
-
- return (\%fields, $text);
-}
-
-1;
-
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list