]> gitweb.ps.run Git - ps-cgit/commitdiff
commit-links.sh: improve regular expressions
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 18 Jul 2011 10:45:20 +0000 (12:45 +0200)
committerLars Hjemli <hjemli@gmail.com>
Tue, 19 Jul 2011 07:12:02 +0000 (07:12 +0000)
The default length for sha1 abbreviations in git is 7.

A '#num' at the beginning of the commit message is now
recognised, a ':#num' as well, etc.: a '#num' anywhere
is now converted to a link.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
filters/commit-links.sh

index d2cd2b33f3ff698ee80ccb1656272340d2d36ff3..58819524ced8eb8f99bec05cfd75f730c27307dc 100755 (executable)
 # CGIT_REPO_CLONE_URL  ( = repo.clone-url setting )
 #
 
+regex=''
+
 # This expression generates links to commits referenced by their SHA1.
 regex=$regex'
-s|\b([0-9a-fA-F]{8,40})\b|<a href="./?id=\1">\1</a>|g'
+s|\b([0-9a-fA-F]{7,40})\b|<a href="./?id=\1">\1</a>|g'
+
 # This expression generates links to a fictional bugtracker.
 regex=$regex'
-s| #([0-9]+)\b|<a href="http://bugs.example.com/?bug=\1">#\1</a>|g'
+s|#([0-9]+)\b|<a href="http://bugs.example.com/?bug=\1">#\1</a>|g'
 
 sed -re "$regex"