aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/sha1.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-04-08 04:54:46 +0200
committerGitHub <noreply@github.com>2020-04-07 22:54:46 -0400
commit3d63caa54245d87dd057d4e853bb5dc7fc39e7db (patch)
tree2fbbb48a39cff157f8cf171b0dad51af366c0908 /modules/git/sha1.go
parent71979d9663d8e43b772c37f2a79af5b8911df661 (diff)
downloadgitea-3d63caa54245d87dd057d4e853bb5dc7fc39e7db.tar.gz
gitea-3d63caa54245d87dd057d4e853bb5dc7fc39e7db.zip
[API] Get a single commit via Ref (#10915)
* GET /repos/:owner/:repo/commits/:ref * add Validation Checks * Fix & Extend TEST * add two new tast cases
Diffstat (limited to 'modules/git/sha1.go')
-rw-r--r--modules/git/sha1.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/git/sha1.go b/modules/git/sha1.go
index 59b8335736..bccc94f103 100644
--- a/modules/git/sha1.go
+++ b/modules/git/sha1.go
@@ -8,6 +8,7 @@ package git
import (
"encoding/hex"
"fmt"
+ "regexp"
"strings"
"github.com/go-git/go-git/v5/plumbing"
@@ -16,6 +17,9 @@ import (
// EmptySHA defines empty git SHA
const EmptySHA = "0000000000000000000000000000000000000000"
+// SHAPattern can be used to determine if a string is an valid sha
+var SHAPattern = regexp.MustCompile(`^[0-9a-f]{4,40}$`)
+
// SHA1 a git commit name
type SHA1 = plumbing.Hash