From: Thierry Parmentelat Date: Fri, 2 Jul 2010 10:44:22 +0000 (+0200) Subject: truncate only hashes, other ids need to remain intact X-Git-Tag: foo~89 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=00e6b066e5dc5f57e12a3c8dc241c34c5a060c9c;p=infrastructure.git truncate only hashes, other ids need to remain intact --- diff --git a/scripts/post-receive-email-with-diffs b/scripts/post-receive-email-with-diffs index 52cbced..66a7bd2 100755 --- a/scripts/post-receive-email-with-diffs +++ b/scripts/post-receive-email-with-diffs @@ -175,6 +175,14 @@ generate_email() generate_email_footer } +# generate a pattern for testing if a string is a hash +hpat="";__=1; while [ $__ -le 40 ] ; do hpat=${hpat}'[0-9a-f]';__=$(($__+1)); done +function is_hash () { + local hash + hash=$1; shift + case $hash in $hpat) return 0;; *) return 1;; esac +} + generate_email_header() { # --- Email (all stdout will be the email) @@ -186,7 +194,7 @@ generate_email_header() details="$refname_type, $short_refname," fi local shortrev - shortrev=$(echo $describe | cut -b1-8) + is_hash $describe && shortrev="$(cut -b1-8 <<< $describe).." || shortrev=$describe # Generate header cat <<-EOF To: $recipients