Skip to content

Instantly share code, notes, and snippets.

@avar
Created September 21, 2016 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avar/0229d15e6eabbed0b8937c9c16a1054a to your computer and use it in GitHub Desktop.
Save avar/0229d15e6eabbed0b8937c9c16a1054a to your computer and use it in GitHub Desktop.
$line = esc_html($line, -nbsp=>1);
$line =~ s{
\b
(
# The output of "git describe", e.g. v2.10.0-297-gf6727b0
# or hadoop-20160921-113441-20-g094fb7d
(?<!-) # see strbuf_check_tag_ref(). Tags can't start with -
[A-Za-z0-9.-]+
(?!\.) # refs can't end with ".", see check_refname_format()
-g[0-9a-fA-F]{7,40}
|
# Just a normal looking Git SHA1
[0-9a-fA-F]{7,40}
)
\b
}{
$cgi->a({-href => href(action=>"object", hash=>$1),
-class => "text"}, $1);
}egx;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment