commit: fix unexpected truncation in title

The commit message should not be treated as locale at all.
pull/5978/head
ᴜɴᴋɴᴡᴏɴ 2020-03-09 02:08:53 +08:00
parent bebaf4c112
commit e87f1107ca
No known key found for this signature in database
GPG Key ID: B43718D76E30A238
3 changed files with 11 additions and 7 deletions

View File

@ -46,9 +46,14 @@ type Context struct {
Org *Organization
}
// Title sets "Title" field in template data.
// RawTitle sets the "Title" field in template data.
func (c *Context) RawTitle(title string) {
c.Data["Title"] = title
}
// Title localizes the "Title" field in template data.
func (c *Context) Title(locale string) {
c.Data["Title"] = c.Tr(locale)
c.RawTitle(c.Tr(locale))
}
// PageIs sets "PageIsxxx" field in template data.

View File

@ -119,7 +119,6 @@ func Diff(c *context.Context) {
commit, err := c.Repo.GitRepo.CatFileCommit(commitID)
if err != nil {
// TODO: Move checker to gitutil package
c.NotFoundOrServerError("get commit by ID", gitutil.IsErrRevisionNotExist, err)
return
}
@ -135,11 +134,11 @@ func Diff(c *context.Context) {
parents := make([]string, commit.ParentsCount())
for i := 0; i < commit.ParentsCount(); i++ {
sha, err := commit.ParentID(i)
parents[i] = sha.String()
if err != nil {
c.NotFound()
return
}
parents[i] = sha.String()
}
setEditorconfigIfExists(c)
@ -147,7 +146,7 @@ func Diff(c *context.Context) {
return
}
c.Title(commit.Summary() + " · " + tool.ShortSHA1(commitID))
c.RawTitle(commit.Summary() + " · " + tool.ShortSHA1(commitID))
c.Data["CommitID"] = commitID
c.Data["IsSplitStyle"] = c.Query("style") == "split"
c.Data["Username"] = userName