mirror of https://github.com/gogs/gogs.git
commit: fix unexpected truncation in title
The commit message should not be treated as locale at all.pull/5978/head
parent
bebaf4c112
commit
e87f1107ca
|
@ -46,9 +46,14 @@ type Context struct {
|
||||||
Org *Organization
|
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) {
|
func (c *Context) Title(locale string) {
|
||||||
c.Data["Title"] = c.Tr(locale)
|
c.RawTitle(c.Tr(locale))
|
||||||
}
|
}
|
||||||
|
|
||||||
// PageIs sets "PageIsxxx" field in template data.
|
// PageIs sets "PageIsxxx" field in template data.
|
||||||
|
|
|
@ -28,7 +28,7 @@ func Test_diffsToHTML(t *testing.T) {
|
||||||
{Type: dmp.DiffEqual, Text: " biz"},
|
{Type: dmp.DiffEqual, Text: " biz"},
|
||||||
},
|
},
|
||||||
lineType: git.DiffLineAdd,
|
lineType: git.DiffLineAdd,
|
||||||
expHTML: template.HTML(`+ foo <span class="added-code">bar</span> biz`),
|
expHTML: template.HTML(`+foo <span class="added-code">bar</span> biz`),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
diffs: []dmp.Diff{
|
diffs: []dmp.Diff{
|
||||||
|
@ -38,7 +38,7 @@ func Test_diffsToHTML(t *testing.T) {
|
||||||
{Type: dmp.DiffEqual, Text: " biz"},
|
{Type: dmp.DiffEqual, Text: " biz"},
|
||||||
},
|
},
|
||||||
lineType: git.DiffLineDelete,
|
lineType: git.DiffLineDelete,
|
||||||
expHTML: template.HTML(`- foo <span class="removed-code">bar</span> biz`),
|
expHTML: template.HTML(`-foo <span class="removed-code">bar</span> biz`),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
@ -119,7 +119,6 @@ func Diff(c *context.Context) {
|
||||||
|
|
||||||
commit, err := c.Repo.GitRepo.CatFileCommit(commitID)
|
commit, err := c.Repo.GitRepo.CatFileCommit(commitID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: Move checker to gitutil package
|
|
||||||
c.NotFoundOrServerError("get commit by ID", gitutil.IsErrRevisionNotExist, err)
|
c.NotFoundOrServerError("get commit by ID", gitutil.IsErrRevisionNotExist, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -135,11 +134,11 @@ func Diff(c *context.Context) {
|
||||||
parents := make([]string, commit.ParentsCount())
|
parents := make([]string, commit.ParentsCount())
|
||||||
for i := 0; i < commit.ParentsCount(); i++ {
|
for i := 0; i < commit.ParentsCount(); i++ {
|
||||||
sha, err := commit.ParentID(i)
|
sha, err := commit.ParentID(i)
|
||||||
parents[i] = sha.String()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.NotFound()
|
c.NotFound()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
parents[i] = sha.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditorconfigIfExists(c)
|
setEditorconfigIfExists(c)
|
||||||
|
@ -147,7 +146,7 @@ func Diff(c *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Title(commit.Summary() + " · " + tool.ShortSHA1(commitID))
|
c.RawTitle(commit.Summary() + " · " + tool.ShortSHA1(commitID))
|
||||||
c.Data["CommitID"] = commitID
|
c.Data["CommitID"] = commitID
|
||||||
c.Data["IsSplitStyle"] = c.Query("style") == "split"
|
c.Data["IsSplitStyle"] = c.Query("style") == "split"
|
||||||
c.Data["Username"] = userName
|
c.Data["Username"] = userName
|
||||||
|
|
Loading…
Reference in New Issue