mirror of
https://github.com/go-gitea/gitea
synced 2024-08-19 22:00:48 +02:00
models/action.go: mirror fix on #892
- modules/base/markdown.go: fix issue link issue - routers/repo/view.go: remove useless code
This commit is contained in:
parent
0669897226
commit
afccd0a3ee
@ -48,7 +48,7 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
IssueCloseKeywordsPat = regexp.MustCompile(fmt.Sprintf(`(?i)(?:%s) \S+`, strings.Join(IssueCloseKeywords, "|")))
|
IssueCloseKeywordsPat = regexp.MustCompile(fmt.Sprintf(`(?i)(?:%s) \S+`, strings.Join(IssueCloseKeywords, "|")))
|
||||||
IssueReferenceKeywordsPat = regexp.MustCompile(fmt.Sprintf(`(?i)(?:) \S+`))
|
IssueReferenceKeywordsPat = regexp.MustCompile(`(?i)(?:)(^| )\S+`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action represents user operation type and other information to repository.,
|
// Action represents user operation type and other information to repository.,
|
||||||
@ -114,6 +114,8 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com
|
|||||||
for _, c := range commits {
|
for _, c := range commits {
|
||||||
references := IssueReferenceKeywordsPat.FindAllString(c.Message, -1)
|
references := IssueReferenceKeywordsPat.FindAllString(c.Message, -1)
|
||||||
|
|
||||||
|
// FIXME: should not be a reference when it comes with action.
|
||||||
|
// e.g. fixes #1 will not have duplicated reference message.
|
||||||
for _, ref := range references {
|
for _, ref := range references {
|
||||||
ref := ref[strings.IndexByte(ref, byte(' '))+1:]
|
ref := ref[strings.IndexByte(ref, byte(' '))+1:]
|
||||||
ref = strings.TrimRightFunc(ref, func(c rune) bool {
|
ref = strings.TrimRightFunc(ref, func(c rune) bool {
|
||||||
@ -128,7 +130,7 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com
|
|||||||
if ref[0] == '#' {
|
if ref[0] == '#' {
|
||||||
ref = fmt.Sprintf("%s/%s%s", repoUserName, repoName, ref)
|
ref = fmt.Sprintf("%s/%s%s", repoUserName, repoName, ref)
|
||||||
} else if strings.Contains(ref, "/") == false {
|
} else if strings.Contains(ref, "/") == false {
|
||||||
// We don't support User#ID syntax yet
|
// FIXME: We don't support User#ID syntax yet
|
||||||
// return ErrNotImplemented
|
// return ErrNotImplemented
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
@ -177,8 +177,8 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
|
|||||||
func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte {
|
func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte {
|
||||||
ms := issueIndexPattern.FindAll(rawBytes, -1)
|
ms := issueIndexPattern.FindAll(rawBytes, -1)
|
||||||
for _, m := range ms {
|
for _, m := range ms {
|
||||||
rawBytes = bytes.Replace(rawBytes, m, []byte(fmt.Sprintf(
|
rawBytes = bytes.Replace(rawBytes, m, []byte(fmt.Sprintf(`<a href="%s/issues/%s">%s</a>`,
|
||||||
`<a href="%s/issues/%s">%s</a>`, urlPrefix, m[1:], m)), -1)
|
urlPrefix, strings.TrimPrefix(string(m[1:]), "#"), m)), -1)
|
||||||
}
|
}
|
||||||
return rawBytes
|
return rawBytes
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,6 @@ func Home(ctx *middleware.Context) {
|
|||||||
entries.Sort()
|
entries.Sort()
|
||||||
|
|
||||||
files := make([][]interface{}, 0, len(entries))
|
files := make([][]interface{}, 0, len(entries))
|
||||||
|
|
||||||
for _, te := range entries {
|
for _, te := range entries {
|
||||||
if te.Type != git.COMMIT {
|
if te.Type != git.COMMIT {
|
||||||
c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
|
c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
|
||||||
@ -151,16 +150,6 @@ func Home(ctx *middleware.Context) {
|
|||||||
files = append(files, []interface{}{te, git.NewSubModuleFile(c, sm.Url, te.Id.String())})
|
files = append(files, []interface{}{te, git.NewSubModuleFile(c, sm.Url, te.Id.String())})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render issue index links.
|
|
||||||
for _, f := range files {
|
|
||||||
switch c := f[1].(type) {
|
|
||||||
case *git.Commit:
|
|
||||||
c.CommitMessage = c.CommitMessage
|
|
||||||
case *git.SubModuleFile:
|
|
||||||
c.CommitMessage = c.CommitMessage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx.Data["Files"] = files
|
ctx.Data["Files"] = files
|
||||||
|
|
||||||
var readmeFile *git.Blob
|
var readmeFile *git.Blob
|
||||||
@ -208,7 +197,6 @@ func Home(ctx *middleware.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastCommit := ctx.Repo.Commit
|
lastCommit := ctx.Repo.Commit
|
||||||
lastCommit.CommitMessage = string(base.RenderIssueIndexPattern([]byte(lastCommit.CommitMessage), ctx.Repo.RepoLink))
|
|
||||||
if len(treePath) > 0 {
|
if len(treePath) > 0 {
|
||||||
c, err := ctx.Repo.Commit.GetCommitOfRelPath(treePath)
|
c, err := ctx.Repo.Commit.GetCommitOfRelPath(treePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user