From a7b1ba0e3d49e699ce7d6e614bc8605aef0a2c9a Mon Sep 17 00:00:00 2001 From: Cherrg Date: Thu, 11 Jul 2019 16:45:10 +0200 Subject: [PATCH] wiki history improvements (#7391) * add history comments to detect page delete Signed-off-by: Michael Gnehr * fix too much history entries - caused by --follow flag - if files with same contents exists Signed-off-by: Michael Gnehr * style imprevements wiki - history - wrap long author names Signed-off-by: Michael Gnehr --- modules/git/repo_commit.go | 10 ++++++++++ public/css/index.css | 2 +- public/less/_markdown.less | 1 + routers/repo/wiki.go | 4 ++-- templates/repo/wiki/revision.tmpl | 16 +++++++++++++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index 8ea2a33145..8429a57039 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -266,6 +266,16 @@ func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) ( return repo.parsePrettyFormatLogToList(stdout) } +// CommitsByFileAndRangeNoFollow return the commits according revison file and the page +func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page int) (*list.List, error) { + stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*50), + "--max-count="+strconv.Itoa(CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path) + if err != nil { + return nil, err + } + return repo.parsePrettyFormatLogToList(stdout) +} + // FilesCountBetween return the number of files changed between two commits func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error) { stdout, err := NewCommand("diff", "--name-only", startCommitID+"..."+endCommitID).RunInDir(repo.Path) diff --git a/public/css/index.css b/public/css/index.css index b948766b41..a260c8c706 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -292,7 +292,7 @@ footer .ui.left,footer .ui.right{line-height:40px} .markdown:not(code) .ui.list .list,.markdown:not(code) ol.ui.list ol,.markdown:not(code) ul.ui.list ul{padding-left:2em} .repository.wiki.revisions .ui.container>.ui.stackable.grid{flex-direction:row-reverse} .repository.wiki.revisions .ui.container>.ui.stackable.grid>.header{margin-top:0} -.repository.wiki.revisions .ui.container>.ui.stackable.grid>.header .sub.header{padding-left:52px} +.repository.wiki.revisions .ui.container>.ui.stackable.grid>.header .sub.header{padding-left:52px;word-break:break-word} .file-revisions-btn{display:block;float:left;margin-bottom:2px!important;padding:11px!important;margin-right:10px!important} .file-revisions-btn i{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none} .home .logo{max-width:220px} diff --git a/public/less/_markdown.less b/public/less/_markdown.less index 1dcc2caf94..8c7b1125c9 100644 --- a/public/less/_markdown.less +++ b/public/less/_markdown.less @@ -505,6 +505,7 @@ .sub.header { padding-left: 52px; + word-break: break-word; } } } diff --git a/routers/repo/wiki.go b/routers/repo/wiki.go index 0fdf853630..0d965f2183 100644 --- a/routers/repo/wiki.go +++ b/routers/repo/wiki.go @@ -248,9 +248,9 @@ func renderRevisionPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) } // get Commit Count - commitsHistory, err := wikiRepo.CommitsByFileAndRange("master", pageFilename, page) + commitsHistory, err := wikiRepo.CommitsByFileAndRangeNoFollow("master", pageFilename, page) if err != nil { - ctx.ServerError("CommitsByFileAndRange", err) + ctx.ServerError("CommitsByFileAndRangeNoFollow", err) return nil, nil } commitsHistory = models.ValidateCommitsWithEmails(commitsHistory) diff --git a/templates/repo/wiki/revision.tmpl b/templates/repo/wiki/revision.tmpl index a64c386edc..c3a4f7636b 100644 --- a/templates/repo/wiki/revision.tmpl +++ b/templates/repo/wiki/revision.tmpl @@ -31,7 +31,7 @@
{{.revision}} {{$title}} -
+
{{$timeSince := TimeSince .Author.When $.Lang}} {{.i18n.Tr "repo.wiki.last_commit_info" .Author.Name $timeSince | Safe}}
@@ -52,8 +52,9 @@ - - + + + @@ -86,6 +87,15 @@ {{end}} + {{end}}
{{.i18n.Tr "repo.commits.author"}}SHA1{{.i18n.Tr "repo.commits.author"}}SHA1{{.i18n.Tr "repo.commits.message"}} {{.i18n.Tr "repo.commits.date"}}
+ + {{.Summary}} + {{if IsMultilineCommitMessage .Message}} + + + {{end}} + + {{TimeSince .Author.When $.Lang}}