[Bps-public-commit] App-Changeloggr branch, master, updated. a3602d88dd78d8ce071a64eaf345de4486aa6197
Alex M Vandiver
alexmv at bestpractical.com
Tue Mar 31 17:45:45 EDT 2009
The branch, master has been updated
via a3602d88dd78d8ce071a64eaf345de4486aa6197 (commit)
via 9a95122669dbb95526ab247956c1a38fa2d15cf5 (commit)
from 01a54cc4b4fe2569fd46d92fd6a16e91f1848cff (commit)
Summary of changes:
lib/App/Changeloggr/Dispatcher.pm | 5 +++++
lib/App/Changeloggr/LogFormat/Git.pm | 3 ++-
lib/App/Changeloggr/Model/Change.pm | 16 ++++++++++++++++
lib/App/Changeloggr/Model/Changelog.pm | 29 +++++++++++++++++++++++++++++
lib/App/Changeloggr/View.pm | 6 ++++++
5 files changed, 58 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 9a95122669dbb95526ab247956c1a38fa2d15cf5
Author: Alex Vandiver <alexmv at mit.edu>
Date: Tue Mar 31 17:44:24 2009 -0400
Strip leading whitespace from commit messages
diff --git a/lib/App/Changeloggr/LogFormat/Git.pm b/lib/App/Changeloggr/LogFormat/Git.pm
index 667f14f..1b5ab14 100644
--- a/lib/App/Changeloggr/LogFormat/Git.pm
+++ b/lib/App/Changeloggr/LogFormat/Git.pm
@@ -55,8 +55,9 @@ sub next_match {
# $fields{commit_date} = $1;
# }
- if ($entry =~ /.*?^(\s{4}.*?)(^\s{1,2}\S+\s+\|\s+\d+|\z)/ims) {
+ if ($entry =~ /.*?^\n(\s{4}.*?)(^\s{1,2}\S+\s+\|\s+\d+|\z)/ims) {
$fields{message} = $1;
+ $fields{message} =~ s/^\s{4}//mg;
}
if ($entry =~ /\n(\s{1,2}\S+\s+\|\s+\d+.*)$/ims) {
$fields{diffstat} = $1;
commit a3602d88dd78d8ce071a64eaf345de4486aa6197
Author: Alex Vandiver <alexmv at mit.edu>
Date: Tue Mar 31 17:45:04 2009 -0400
Add a Changes output format, based on Jifty's formatting
diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index 7c56056..5de4c7e 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -18,6 +18,11 @@ on '/changelog/*' => run {
show '/changelog';
};
+on '/changelog/*/Changes' => run {
+ set name => $1;
+ show '/changelog/download';
+};
+
on '/changelog/admin/*' => run {
my $uuid = $1;
set id => Changelog(admin_token => $uuid)->id;
diff --git a/lib/App/Changeloggr/Model/Change.pm b/lib/App/Changeloggr/Model/Change.pm
index aaae540..7e16ee8 100644
--- a/lib/App/Changeloggr/Model/Change.pm
+++ b/lib/App/Changeloggr/Model/Change.pm
@@ -51,6 +51,22 @@ sub current_user_can {
return $self->SUPER::current_user_can($right, @_);
}
+sub grouped_votes {
+ my $self = shift;
+ my $votes = App::Changeloggr::Model::VoteCollection->new;
+ $votes->limit( column => 'change', value => $self->id );
+ $votes->column(
+ column => 'tag',
+ );
+ $votes->group_by(
+ column => 'tag',
+ );
+ $votes->order_by(
+ function => 'count(*)',
+ order => 'desc',
+ );
+ return $votes;
+}
1;
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index ece7cc5..8892dad 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -98,5 +98,34 @@ sub choose_change {
return $changes->first;
}
+sub generate {
+ my $self = shift;
+ my $changes = $self->changes;
+ $changes->order_by(column => 'date');
+ my %categories;
+ while (my $change = $changes->next) {
+ my $votes = $change->grouped_votes;
+ if (my $winner = $votes->first) {
+ push @{$categories{$winner->tag}}, $change;
+ } else {
+ push @{$categories{unknown}}, $change;
+ }
+ }
+
+ my $str = "Changelog for ". $self->name.", generated ".Jifty::DateTime->now."\n\n";
+ for my $cat (sort keys %categories) {
+ $str .= uc($cat) . "\n" . ("=" x length($cat)) . "\n";
+ for my $change (@{$categories{$cat}}) {
+ my $msg = " * " . $change->message;
+ $msg =~ s/\n*\Z//;
+ $msg =~ s/\n/\n /g;
+ $msg =~ s/\n\s+\n/\n\n/g;
+ $str .= $msg . "\n";
+ }
+ $str .= "\n";
+ }
+ return $str;
+}
+
1;
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index ddbd119..d2efd93 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -46,6 +46,12 @@ template '/changelog' => page {
);
};
+template '/changelog/download' => sub {
+ my $changelog = Changelog(name => get('name'));
+ Jifty->handler->apache->header_out('Content-Type' => 'text/plain');
+ outs_raw( $changelog->generate );
+};
+
template '/vote-on-change' => sub {
my $changelog = M('Changelog', id => get('changelog'));
my $change = $changelog->choose_change;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list