[Bps-public-commit] r11629 - in App-Changelogger: bin

sartak at bestpractical.com sartak at bestpractical.com
Tue Apr 8 01:52:34 EDT 2008


Author: sartak
Date: Tue Apr  8 01:52:34 2008
New Revision: 11629

Modified:
   App-Changelogger/   (props changed)
   App-Changelogger/bin/sort-changelog

Log:
 r53628 at onn:  sartak | 2008-04-08 01:51:50 -0400
 Add a way to split commits for those pesky mega-commits


Modified: App-Changelogger/bin/sort-changelog
==============================================================================
--- App-Changelogger/bin/sort-changelog	(original)
+++ App-Changelogger/bin/sort-changelog	Tue Apr  8 01:52:34 2008
@@ -9,11 +9,12 @@
 use Text::Autoformat;
 
 my %commands = (
-    j   => sub { ++$_ },
-    k   => sub { --$_ },
-    q   => sub { die "Quitting.\n" },
-    e   => \&edit_entry,
-    t   => \&next_tag,
+    j => sub { ++$_ },
+    k => sub { --$_ },
+    q => sub { die "Quitting.\n" },
+    e => \&edit_entry,
+    s => \&split_entry,
+    t => \&next_tag,
 );
 
 my %tags = (
@@ -55,6 +56,7 @@
 k - previous entry
 q - write and quit
 e - edit entry
+s - split entry by adding -- lines
 t - find next entry with a different tag
 
 HELP
@@ -177,6 +179,23 @@
     $entry->{msg} = reformat_message($entry->{msg});
 }
 
+sub split_entry {
+    my $entry = shift;
+    my ($fh, $fn) = solicit($entry->{msg});
+    close $fh;
+    my $msg = do { local (@ARGV, $/) = $fn; <> };
+
+    my @msgs = map { reformat_message($_) }
+               grep { /\S/ }
+               split /\n-+\n/, $msg;
+
+    $entry->{msg} = shift @msgs;
+    my @new_entries = map { my %copy = %$entry; $copy{msg} = $_; \%copy } @msgs;
+
+    # add the new entries right after the current one
+    splice @entries, $_ + 1, 0, @new_entries;
+}
+
 sub next_tag {
     my $start = $_;
     my $section = $_[0]->{section};



More information about the Bps-public-commit mailing list