summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorGary Kim <gary@garykim.dev>2019-08-14 08:04:55 +0000
committerLunny Xiao <xiaolunwen@gmail.com>2019-08-14 16:04:55 +0800
commit7eed11e5e9855324dd328a99133bf1f668076f80 (patch)
tree664c36efdc7697b270cb3c819a3f3274a2d8517c /models
parent46d6b92ad04df87560ee12dfee58a5e8222e52ff (diff)
downloadgitea-7eed11e5e9855324dd328a99133bf1f668076f80.tar.gz
gitea-7eed11e5e9855324dd328a99133bf1f668076f80.zip
Check commit message hashes before making links (#7713)
* Check commit message hashes before making links Previously, when formatting commit messages, anything that looked like SHA1 hashes was turned into a link using regex. This meant that certain phrases or numbers such as `777777` or `deadbeef` could be recognized as a commit even if the repository has no commit with those hashes. This change will make it so that anything that looks like a SHA1 hash using regex will then also be checked to ensure that there is a commit in the repository with that hash before making a link. Signed-off-by: Gary Kim <gary@garykim.dev> * Use gogit to check if commit exists This commit modifies the commit hash check in the render for commit messages to use gogit for better performance. Signed-off-by: Gary Kim <gary@garykim.dev> * Make code cleaner Signed-off-by: Gary Kim <gary@garykim.dev> * Use rev-parse to check if commit exists Signed-off-by: Gary Kim <gary@garykim.dev> * Add and modify tests for checking hashes in html link rendering Signed-off-by: Gary Kim <gary@garykim.dev> * Return error in sha1CurrentPatternProcessor Co-Authored-By: mrsdizzie <info@mrsdizzie.com> * Import Gitea log module Signed-off-by: Gary Kim <gary@garykim.dev> * Revert "Return error in sha1CurrentPatternProcessor" This reverts commit 28f561cac46ef7e51aa26aefcbe9aca4671366a6. Signed-off-by: Gary Kim <gary@garykim.dev> * Add debug logging to sha1CurrentPatternProcessor This will log errors by the git command run in sha1CurrentPatternProcessor if the error is one that was unexpected. Signed-off-by: Gary Kim <gary@garykim.dev>
Diffstat (limited to 'models')
-rw-r--r--models/repo.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/models/repo.go b/models/repo.go
index 86370821d3..b0e59f26b6 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -508,8 +508,9 @@ func (repo *Repository) mustOwnerName(e Engine) string {
func (repo *Repository) ComposeMetas() map[string]string {
if repo.ExternalMetas == nil {
repo.ExternalMetas = map[string]string{
- "user": repo.MustOwner().Name,
- "repo": repo.Name,
+ "user": repo.MustOwner().Name,
+ "repo": repo.Name,
+ "repoPath": repo.RepoPath(),
}
unit, err := repo.GetUnit(UnitTypeExternalTracker)
if err != nil {