[vhffs-dev] [2220] sanitize mercurial description data to match .hgrc requirements ( no empty lines)

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2220
Author:   gradator
Date:     2012-12-30 18:27:31 +0100 (Sun, 30 Dec 2012)
Log Message:
-----------
sanitize mercurial description data to match .hgrc requirements (no empty lines)

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm

Modified: trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm	2012-11-05 17:31:57 UTC (rev 2219)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm	2012-12-30 17:27:31 UTC (rev 2220)
@@ -157,8 +157,11 @@
 	}
 
 	my $description = $mercurial->get_description;
-	# multi line values should be indented
-	$description =~ s/(\r)?\n/\n  /g;
+	$description =~ s/\r\n/\n/g; # change CRLF to LF
+	$description =~ s/\n\s*\n/\n/g; # remove empty lines (mercurial does not handle description with empty lines because .hgrc discard empty lines)
+	$description =~ s/^\n//; # remove first LF
+	$description =~ s/\n$//; # remove latest LF
+	$description =~ s/\n/\n  /g; # multi line values should be indented
 
 	print $rcfileout '[web]'."\n";
 	print $rcfileout 'description ='."\n".'  '.$description."\n";


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/