diff --git a/modules/template/template.go b/modules/template/template.go
index d0d77b017..9d63452dd 100644
--- a/modules/template/template.go
+++ b/modules/template/template.go
@@ -183,15 +183,27 @@ func ReplaceLeft(s, old, new string) string {
}
// RenderCommitMessage renders commit message with XSS-safe and special links.
-func RenderCommitMessage(msg, urlPrefix string, metas map[string]string) template.HTML {
+func RenderCommitMessage(full bool, msg, urlPrefix string, metas map[string]string) template.HTML {
cleanMsg := template.HTMLEscapeString(msg)
fullMessage := string(base.RenderIssueIndexPattern([]byte(cleanMsg), urlPrefix, metas))
msgLines := strings.Split(strings.TrimSpace(fullMessage), "\n")
- for i := range msgLines {
- msgLines[i] = ReplaceLeft(msgLines[i], " ", " ")
+ numLines := len(msgLines)
+ if numLines == 0 {
+ return template.HTML("")
+ } else if !full {
+ return template.HTML(msgLines[0])
+ } else if numLines == 1 || (numLines >= 2 && len(msgLines[1]) == 0) {
+ // First line is a header, standalone or followed by empty line
+ header := fmt.Sprintf("
%s
", msgLines[0])
+ if numLines >= 2 {
+ fullMessage = header + fmt.Sprintf("\n%s
", strings.Join(msgLines[2:], "\n"))
+ } else {
+ fullMessage = header
+ }
+ } else {
+ // Non-standard git message, there is no header line
+ fullMessage = fmt.Sprintf("%s
", strings.Join(msgLines, "
"))
}
-
- fullMessage = strings.Join(msgLines, "
")
return template.HTML(fullMessage)
}
diff --git a/public/css/gogs.css b/public/css/gogs.css
index 583297afe..56a64cfd8 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -895,13 +895,22 @@ pre.raw {
.ui .warning.segment {
border-color: #F0C36D;
}
-.ui .info.header {
- background-color: #d9edf7 !important;
- border-color: #85c5e5;
-}
.ui .info.segment {
border-color: #85c5e5;
}
+.ui .info.segment.top {
+ background-color: #d9edf7 !important;
+}
+.ui .info.segment.top h3,
+.ui .info.segment.top h4 {
+ margin-top: 0;
+}
+.ui .info.segment.top h3:last-child {
+ margin-top: 4px;
+}
+.ui .info.segment.top > :last-child {
+ margin-bottom: 0;
+}
.ui .normal.header {
font-weight: normal;
}
diff --git a/public/less/_base.less b/public/less/_base.less
index bd51f2303..e35936342 100644
--- a/public/less/_base.less
+++ b/public/less/_base.less
@@ -196,12 +196,20 @@ pre {
}
}
.info {
- &.header {
- background-color: #d9edf7 !important;
- border-color: #85c5e5;
- }
&.segment {
- border-color: #85c5e5;
+ border-color: #85c5e5;
+ &.top {
+ background-color: #d9edf7 !important;
+ h3, h4 {
+ margin-top: 0;
+ }
+ h3:last-child {
+ margin-top: 4px;
+ }
+ > :last-child {
+ margin-bottom: 0;
+ }
+ }
}
}
diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl
index 2adc1770f..8bab2be00 100644
--- a/templates/repo/commits_table.tmpl
+++ b/templates/repo/commits_table.tmpl
@@ -37,7 +37,7 @@
{{ShortSha .ID.String}}
- {{RenderCommitMessage .Summary $.RepoLink $.Repository.ComposeMetas}}
+ {{RenderCommitMessage false .Summary $.RepoLink $.Repository.ComposeMetas}}
|
{{TimeSince .Author.When $.Lang}} |
diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl
index ba1322e43..18de976eb 100644
--- a/templates/repo/diff.tmpl
+++ b/templates/repo/diff.tmpl
@@ -5,14 +5,12 @@
{{if .IsDiffCompare }}
{{template "repo/commits_table" .}}
{{else}}
-
+
{{if .Author}}
diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl
index 9fb71908a..887ce8e25 100644
--- a/templates/repo/view_list.tmpl
+++ b/templates/repo/view_list.tmpl
@@ -10,7 +10,7 @@
{{.LastCommit.Author.Name}}
{{end}}
{{ShortSha .LastCommit.ID.String}}
-
{{RenderCommitMessage .LastCommit.Summary .RepoLink $.Repository.ComposeMetas}}
+
{{RenderCommitMessage false .LastCommit.Summary .RepoLink $.Repository.ComposeMetas}}
|
@@ -44,7 +44,7 @@
{{end}}
{{ShortSha $commit.ID.String}}
- {{RenderCommitMessage $commit.Summary $.RepoLink $.Repository.ComposeMetas}}
+ {{RenderCommitMessage false $commit.Summary $.RepoLink $.Repository.ComposeMetas}}
|
{{TimeSince $commit.Committer.When $.Lang}} |