From 7eafe3213f456bb4fcbaeea5562ab60c4ef6cf87 Mon Sep 17 00:00:00 2001 From: Thibault Meyer <0xbaadf00d@users.noreply.github.com> Date: Fri, 12 Aug 2016 00:34:00 +0200 Subject: Fix #3321: commit tag shortener (#3418) * Fix #3321: commit tag shortener * Check short commit * remove debug * Edit unit tests * Show 10-char short SHA --- modules/base/tool.go | 2 +- modules/markdown/markdown.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/base/tool.go b/modules/base/tool.go index 6088daf0..cf8fece0 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -45,7 +45,7 @@ func EncodeSha1(str string) string { } func ShortSha(sha1 string) string { - if len(sha1) == 40 { + if len(sha1) > 10 { return sha1[:10] } return sha1 diff --git a/modules/markdown/markdown.go b/modules/markdown/markdown.go index 92a61549..1da1c5e2 100644 --- a/modules/markdown/markdown.go +++ b/modules/markdown/markdown.go @@ -90,7 +90,7 @@ var ( IssueAlphanumericPattern = regexp.MustCompile(`( |^|\()[A-Z]{1,10}-[1-9][0-9]*\b`) // Sha1CurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae - Sha1CurrentPattern = regexp.MustCompile(`\b[0-9a-f]{40}\b`) + Sha1CurrentPattern = regexp.MustCompile(`\b[0-9a-f]{7,40}\b`) ) // FindAllMentions matches mention patterns in given content -- cgit v1.2.3