[Bps-public-commit] App-Changeloggr branch, master, updated. 2f266c1bf6357146bebc629da83cdcba670b933c

sartak at bestpractical.com sartak at bestpractical.com
Wed May 27 15:44:39 EDT 2009


The branch, master has been updated
       via  2f266c1bf6357146bebc629da83cdcba670b933c (commit)
      from  a6fda5d50e2b99d2877866203b6284beeefba67b (commit)

Summary of changes:
 lib/App/Changeloggr/InputFormat.pm |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

- Log -----------------------------------------------------------------
commit 2f266c1bf6357146bebc629da83cdcba670b933c
Author: Shawn M Moore <sartak at gmail.com>
Date:   Wed May 27 15:44:24 2009 -0400

    Strip a fixed amount of leading whitespace from the commit message

diff --git a/lib/App/Changeloggr/InputFormat.pm b/lib/App/Changeloggr/InputFormat.pm
index 5fc1c19..51eab44 100644
--- a/lib/App/Changeloggr/InputFormat.pm
+++ b/lib/App/Changeloggr/InputFormat.pm
@@ -58,6 +58,27 @@ sub strip_detritus {
     # Remove extra newlines at the end of the message
     $msg =~ s/\s+\z//;
 
+    $msg = $self->strip_leading_whitespace($msg);
+
+    return $msg;
+}
+
+sub strip_leading_whitespace {
+    my $self = shift;
+    my $msg  = shift;
+
+    # Find the minimum amount of whitespace on a non-empty line
+    my $minimum;
+    for my $line (grep { /\S/ } split /\n/, $msg) {
+        my ($space) = $line =~ /^( *)/;
+        $minimum = length($space)
+            if !defined($minimum)
+            || $minimum > length($space);
+    }
+
+    # Remove that minimum from each line
+    $msg =~ s/^( {$minimum})//mg;
+
     return $msg;
 }
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list