Revision: 2267
http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2267&view=rev
Author: dermoth
Date: 2009-10-24 21:00:41 +0000 (Sat, 24 Oct 2009)
Log Message:
-----------
git-notify: Truncate summary after 50 characters
If the first line of a commit message is longer than 50 characters,
truncate it before adding the resulting string to the subject line of a
notification. This makes sure the subject line won't get too long
(unless the commit author name is unusually long, which we don't check).
The Git User's Manual recommends keeping the first line of a commit
message shorter than that, anyway:
| Though not required, it's a good idea to begin the commit message with
| a single short (less than 50 character) line summarizing the change,
| followed by a blank line and then a more thorough description. Tools
| that turn commits into email, for example, use the first line on the
| Subject line and the rest of the commit in the body.
[ http://www.kernel.org/pub/software/scm/git/docs/user-manual.html ]
From: Holger Weiss <[email protected]>
Modified Paths:
--------------
nagiosplug/trunk/tools/git-notify
Modified: nagiosplug/trunk/tools/git-notify
===================================================================
--- nagiosplug/trunk/tools/git-notify 2009-10-24 21:00:35 UTC (rev 2266)
+++ nagiosplug/trunk/tools/git-notify 2009-10-24 21:00:41 UTC (rev 2267)
@@ -127,6 +127,20 @@
return $revlist;
}
+# truncate the given string if it exceeds the specified number of characters
+sub truncate_str($$)
+{
+ my ($str, $max) = @_;
+
+ if (length($str) > $max)
+ {
+ $str = substr($str, 0, $max);
+ $str =~ s/\s+\S+$//;
+ $str .= " ...";
+ }
+ return $str;
+}
+
# right-justify the left column of "left: right" elements, omit undefined elements
sub format_table(@)
{
@@ -338,7 +352,7 @@
}
mail_notification($commitlist_address,
- $info{"author_name"} . ": " . ${$info{"log"}}[0],
+ $info{"author_name"} . ": " . truncate_str(${$info{"log"}}[0], 50),
"text/plain; charset=UTF-8", @notice);
$sent_notices++;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.