mirror of
https://github.com/gogs/gogs.git
synced 2025-05-25 17:00:55 +00:00
templates/repo: only show Git stats in repository home page (#3518)
Move 'Commits' and 'Releases' tabs down to body. This patch also reduces page load time for pages that do not need to use commits count anywhere. Get commits count can hurt performance badly for huge repositories that has tens of thousands commits like Linux Kernel.
This commit is contained in:
parent
451aef7a1c
commit
ebc0943713
@ -426,8 +426,8 @@ issues = Issues
|
|||||||
pulls = Pull Requests
|
pulls = Pull Requests
|
||||||
labels = Labels
|
labels = Labels
|
||||||
milestones = Milestones
|
milestones = Milestones
|
||||||
commits = Commits
|
commits = commits
|
||||||
releases = Releases
|
releases = releases
|
||||||
file_raw = Raw
|
file_raw = Raw
|
||||||
file_history = History
|
file_history = History
|
||||||
file_view_raw = View Raw
|
file_view_raw = View Raw
|
||||||
|
File diff suppressed because one or more lines are too long
@ -456,13 +456,6 @@ func RepoRef() macaron.Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.Data["PullRequestCtx"] = ctx.Repo.PullRequest
|
ctx.Data["PullRequestCtx"] = ctx.Repo.PullRequest
|
||||||
|
|
||||||
ctx.Repo.CommitsCount, err = ctx.Repo.Commit.CommitsCount()
|
|
||||||
if err != nil {
|
|
||||||
ctx.Handle(500, "CommitsCount", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"CodeKitInfo": "This is a CodeKit 2.x project configuration file. It is designed to sync project settings across multiple machines. MODIFYING THE CONTENTS OF THIS FILE IS A POOR LIFE DECISION. If you do so, you will likely cause CodeKit to crash. This file is not useful unless accompanied by the project that created it in CodeKit 2. This file is not backwards-compatible with CodeKit 1.x. For more information, see: http:\/\/incident57.com\/codekit",
|
"CodeKitInfo": "This is a CodeKit 2.x project configuration file. It is designed to sync project settings across multiple machines. MODIFYING THE CONTENTS OF THIS FILE IS A POOR LIFE DECISION. If you do so, you will likely cause CodeKit to crash. This file is not useful unless accompanied by the project that created it in CodeKit 2. This file is not backwards-compatible with CodeKit 1.x. For more information, see: http:\/\/incident57.com\/codekit",
|
||||||
"creatorBuild": "19115",
|
"creatorBuild": "19127",
|
||||||
"files": {
|
"files": {
|
||||||
"\/css\/github.min.css": {
|
"\/css\/github.min.css": {
|
||||||
"fileType": 16,
|
"fileType": 16,
|
||||||
@ -66,7 +66,7 @@
|
|||||||
"fileType": 32768,
|
"fileType": 32768,
|
||||||
"ignore": 0,
|
"ignore": 0,
|
||||||
"ignoreWasSetByUser": 0,
|
"ignoreWasSetByUser": 0,
|
||||||
"initialSize": 4048,
|
"initialSize": 514087,
|
||||||
"inputAbbreviatedPath": "\/img\/avatar_default.png",
|
"inputAbbreviatedPath": "\/img\/avatar_default.png",
|
||||||
"outputAbbreviatedPath": "\/img\/avatar_default.png",
|
"outputAbbreviatedPath": "\/img\/avatar_default.png",
|
||||||
"outputPathIsOutsideProject": 0,
|
"outputPathIsOutsideProject": 0,
|
||||||
|
@ -125,6 +125,11 @@ code.wrap {
|
|||||||
.ui.form .ui.button {
|
.ui.form .ui.button {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
.ui.menu,
|
||||||
|
.ui.vertical.menu,
|
||||||
|
.ui.segment {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
.ui .text.red {
|
.ui .text.red {
|
||||||
color: #d95c5c !important;
|
color: #d95c5c !important;
|
||||||
}
|
}
|
||||||
@ -1235,6 +1240,20 @@ footer .ui.language .menu {
|
|||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
.repository.file.list #git-stats {
|
||||||
|
padding: 5px 10px;
|
||||||
|
line-height: 0;
|
||||||
|
}
|
||||||
|
.repository.file.list #git-stats .list {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.repository.file.list #git-stats .list .item {
|
||||||
|
margin-left: 0;
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
.repository.file.list #git-stats .list .item .text b {
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
.repository.file.list #repo-files-table thead th {
|
.repository.file.list #repo-files-table thead th {
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
@ -2427,10 +2446,6 @@ footer .ui.language .menu {
|
|||||||
.settings .content {
|
.settings .content {
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
}
|
}
|
||||||
.settings .content > .header,
|
|
||||||
.settings .content .segment {
|
|
||||||
box-shadow: 0 1px 2px 0 rgba(34, 36, 38, 0.15);
|
|
||||||
}
|
|
||||||
.settings .key.list .item:not(:first-child) {
|
.settings .key.list .item:not(:first-child) {
|
||||||
border-top: 1px solid #eaeaea;
|
border-top: 1px solid #eaeaea;
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,12 @@ pre, code {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.menu,
|
||||||
|
&.vertical.menu,
|
||||||
|
&.segment {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
&.red {
|
&.red {
|
||||||
color: #d95c5c !important;
|
color: #d95c5c !important;
|
||||||
|
@ -167,6 +167,20 @@
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#git-stats {
|
||||||
|
padding: 5px 10px;
|
||||||
|
line-height: 0;
|
||||||
|
.list {
|
||||||
|
width: 100%;
|
||||||
|
.item {
|
||||||
|
margin-left: 0;
|
||||||
|
width: 50%;
|
||||||
|
.text b {
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#repo-files-table {
|
#repo-files-table {
|
||||||
thead {
|
thead {
|
||||||
@ -1476,10 +1490,6 @@
|
|||||||
.settings {
|
.settings {
|
||||||
.content {
|
.content {
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
>.header,
|
|
||||||
.segment {
|
|
||||||
box-shadow: 0 1px 2px 0 rgba(34,36,38,.15);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.key.list {
|
.key.list {
|
||||||
.item:not(:first-child) {
|
.item:not(:first-child) {
|
||||||
|
@ -280,7 +280,7 @@ func ViewPullCommits(ctx *context.Context) {
|
|||||||
|
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
commits = models.ValidateCommitsWithEmails(commits)
|
||||||
ctx.Data["Commits"] = commits
|
ctx.Data["Commits"] = commits
|
||||||
ctx.Data["CommitCount"] = commits.Len()
|
ctx.Data["CommitsCount"] = commits.Len()
|
||||||
|
|
||||||
ctx.HTML(200, PULL_COMMITS)
|
ctx.HTML(200, PULL_COMMITS)
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,6 @@ const (
|
|||||||
|
|
||||||
// calReleaseNumCommitsBehind calculates given release has how many commits behind release target.
|
// calReleaseNumCommitsBehind calculates given release has how many commits behind release target.
|
||||||
func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *models.Release, countCache map[string]int64) error {
|
func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *models.Release, countCache map[string]int64) error {
|
||||||
// Fast return if release target is same as default branch.
|
|
||||||
if repoCtx.BranchName == release.Target {
|
|
||||||
release.NumCommitsBehind = repoCtx.CommitsCount - release.NumCommits
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get count if not exists
|
// Get count if not exists
|
||||||
if _, ok := countCache[release.Target]; !ok {
|
if _, ok := countCache[release.Target]; !ok {
|
||||||
if repoCtx.GitRepo.IsBranchExist(release.Target) {
|
if repoCtx.GitRepo.IsBranchExist(release.Target) {
|
||||||
|
@ -238,9 +238,22 @@ func Home(ctx *context.Context) {
|
|||||||
treeLink := branchLink
|
treeLink := branchLink
|
||||||
rawLink := ctx.Repo.RepoLink + "/raw/" + ctx.Repo.BranchName
|
rawLink := ctx.Repo.RepoLink + "/raw/" + ctx.Repo.BranchName
|
||||||
|
|
||||||
|
isRootDir := false
|
||||||
if len(ctx.Repo.TreePath) > 0 {
|
if len(ctx.Repo.TreePath) > 0 {
|
||||||
treeLink += "/" + ctx.Repo.TreePath
|
treeLink += "/" + ctx.Repo.TreePath
|
||||||
|
} else {
|
||||||
|
isRootDir = true
|
||||||
|
|
||||||
|
// Only show Git stats panel when view root directory
|
||||||
|
var err error
|
||||||
|
ctx.Repo.CommitsCount, err = ctx.Repo.Commit.CommitsCount()
|
||||||
|
if err != nil {
|
||||||
|
ctx.Handle(500, "CommitsCount", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
|
||||||
}
|
}
|
||||||
|
ctx.Data["PageIsRepoHome"] = isRootDir
|
||||||
|
|
||||||
// Get current entry user currently looking at.
|
// Get current entry user currently looking at.
|
||||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath)
|
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath)
|
||||||
|
@ -62,12 +62,6 @@
|
|||||||
<i class="octicon octicon-git-pull-request"></i> {{.i18n.Tr "repo.pulls"}} <span class="ui {{if not .Repository.NumOpenPulls}}gray{{else}}blue{{end}} small label">{{.Repository.NumOpenPulls}}</span>
|
<i class="octicon octicon-git-pull-request"></i> {{.i18n.Tr "repo.pulls"}} <span class="ui {{if not .Repository.NumOpenPulls}}gray{{else}}blue{{end}} small label">{{.Repository.NumOpenPulls}}</span>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
<a class="{{if (or (.PageIsCommits) (.PageIsDiff))}}active{{end}} item" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}">
|
|
||||||
<i class="octicon octicon-history"></i> {{.i18n.Tr "repo.commits"}} <span class="ui {{if not .CommitsCount}}gray{{else}}blue{{end}} small label">{{.CommitsCount}}</span>
|
|
||||||
</a>
|
|
||||||
<a class="{{if .PageIsReleaseList}}active{{end}} item" href="{{.RepoLink}}/releases">
|
|
||||||
<i class="octicon octicon-tag"></i> {{.i18n.Tr "repo.releases"}} <span class="ui {{if not .Repository.NumTags}}gray{{else}}blue{{end}} small label">{{.Repository.NumTags}}</span>
|
|
||||||
</a>
|
|
||||||
{{if .Repository.EnableWiki}}
|
{{if .Repository.EnableWiki}}
|
||||||
<a class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki">
|
<a class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki">
|
||||||
<i class="octicon octicon-book"></i> {{.i18n.Tr "repo.wiki"}}
|
<i class="octicon octicon-book"></i> {{.i18n.Tr "repo.wiki"}}
|
||||||
|
@ -3,10 +3,22 @@
|
|||||||
{{template "repo/header" .}}
|
{{template "repo/header" .}}
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
{{template "base/alert" .}}
|
{{template "base/alert" .}}
|
||||||
<p id="repo-desc">
|
{{if .PageIsRepoHome}}
|
||||||
{{if .Repository.DescriptionHtml}}<span class="description has-emoji">{{.Repository.DescriptionHtml}}</span>{{else}}<span class="no-description text-italic">{{.i18n.Tr "repo.no_desc"}}</span>{{end}}
|
<p id="repo-desc">
|
||||||
<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>
|
{{if .Repository.DescriptionHtml}}<span class="description has-emoji">{{.Repository.DescriptionHtml}}</span>{{else}}<span class="no-description text-italic">{{.i18n.Tr "repo.no_desc"}}</span>{{end}}
|
||||||
</p>
|
<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>
|
||||||
|
</p>
|
||||||
|
<div class="ui segment" id="git-stats">
|
||||||
|
<div class="ui two horizontal center link list">
|
||||||
|
<div class="item">
|
||||||
|
<a href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}"><span class="ui text black"><i class="octicon octicon-history"></i> <b>{{.CommitsCount}}</b> {{.i18n.Tr "repo.commits"}}</span> </a>
|
||||||
|
</div>
|
||||||
|
<div class="item">
|
||||||
|
<a href="{{.RepoLink}}/releases"><span class="ui text black"><i class="octicon octicon-tag"></i> <b>{{.Repository.NumTags}}</b> {{.i18n.Tr "repo.releases"}}</span> </a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
<div class="ui secondary menu">
|
<div class="ui secondary menu">
|
||||||
{{if .PullRequestCtx.Allowed}}
|
{{if .PullRequestCtx.Allowed}}
|
||||||
<div class="fitted item">
|
<div class="fitted item">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user