Commits

Martin Geisler committed d2c8ba7

Strip description as in Mercurial changeset fb9b83df45f3

Comments (0)

Files changed (3)

 # commitsigs.py - sign changesets upon commit
 #
-# Copyright 2009 Matt Mackall <mpm@selenic.com> and others
+# Copyright 2009, 2010 Matt Mackall <mpm@selenic.com> and others
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2, incorporated herein by reference.
     if "\n" in user:
         raise error.RevlogError(_("username %s contains a newline")
                                 % repr(user))
+
+    # strip trailing whitespace and leading and trailing empty lines
+    desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')
+
     user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
 
     if date:

tests/test-commitsigs

 hg push -q 2>&1 | sed 's|:[0-9a-f]\+:|:XXXXXXXXXXXX:|'
 
 
+cat >> logmsg <<EOF
+A long commit message with
+trailing whitespace.
+
+
+
+EOF
+
+echo >> a.txt
+echo "% Commit with trailing whitespace"
+hg commit -l logmsg -d '3500 0'
+
+hgverifysigs
+
 cat >> $HGRCPATH <<EOF
 [commitsigs]
 scheme = x

tests/test-commitsigs.out

 transaction abort!
 rollback completed
 abort: could not verify all new changesets
+% Commit with trailing whitespace
+% hg verifysigs (exit code: 1)
+0:XXXXXXXXXXXX: ** no signature
+1:XXXXXXXXXXXX: good gnupg signature
+2:XXXXXXXXXXXX: good openssl signature
+3:XXXXXXXXXXXX: ** no signature
+4:XXXXXXXXXXXX: good openssl signature
+% hg verifysigs --only-heads (exit code: 0)
+4:XXXXXXXXXXXX: good openssl signature
 % unknown scheme
 abort: unknown signature scheme: x