new commits table
This commit is contained in:
Родитель
d7c3c79c00
Коммит
aa65761d81
|
@ -166,6 +166,13 @@ type Repository struct {
|
|||
Updated time.Time `xorm:"UPDATED"`
|
||||
}
|
||||
|
||||
func (repo *Repository) AfterSet(colName string, _ xorm.Cell) {
|
||||
switch colName {
|
||||
case "updated":
|
||||
repo.Updated = regulateTimeZone(repo.Updated)
|
||||
}
|
||||
}
|
||||
|
||||
func (repo *Repository) getOwner(e Engine) (err error) {
|
||||
if repo.Owner == nil {
|
||||
repo.Owner, err = getUserByID(e, repo.OwnerID)
|
||||
|
|
|
@ -275,9 +275,11 @@ func (repo *Repository) searchCommits(id sha1, keyword string) (*list.List, erro
|
|||
return parsePrettyFormatLog(repo, stdout)
|
||||
}
|
||||
|
||||
var CommitsRangeSize = 50
|
||||
|
||||
func (repo *Repository) commitsByRange(id sha1, page int) (*list.List, error) {
|
||||
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", id.String(),
|
||||
"--skip="+com.ToStr((page-1)*50), "--max-count=50", prettyLogFormat)
|
||||
"--skip="+com.ToStr((page-1)*CommitsRangeSize), "--max-count="+com.ToStr(CommitsRangeSize), prettyLogFormat)
|
||||
if err != nil {
|
||||
return nil, errors.New(string(stderr))
|
||||
}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,6 +1,6 @@
|
|||
.admin {
|
||||
padding-top: 15px;
|
||||
padding-bottom: @footer-margin * 3;
|
||||
padding-bottom: @footer-margin * 2;
|
||||
|
||||
.table.segment {
|
||||
padding: 0;
|
||||
|
|
|
@ -92,6 +92,13 @@ img {
|
|||
&.small {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
&.truncate {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.message {
|
||||
|
|
|
@ -9,7 +9,11 @@
|
|||
.ui.attached.header {
|
||||
background: #f0f0f0;
|
||||
.right {
|
||||
margin-top: -6px;
|
||||
margin-top: -5px;
|
||||
.button {
|
||||
padding: 8px 10px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
.repository {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.home {
|
||||
padding-bottom: @footer-margin * 3;
|
||||
padding-bottom: @footer-margin * 2;
|
||||
.logo {
|
||||
max-width: 250px;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.install {
|
||||
padding-top: 45px;
|
||||
padding-bottom: @footer-margin * 3;
|
||||
padding-bottom: @footer-margin * 2;
|
||||
form {
|
||||
@input-padding: 320px !important;
|
||||
label {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
@mega-octicon-width: 30px;
|
||||
|
||||
padding-top: 15px;
|
||||
padding-bottom: @footer-margin * 3;
|
||||
padding-bottom: @footer-margin * 2;
|
||||
|
||||
.head {
|
||||
.column {
|
||||
|
@ -424,6 +424,52 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.commits {
|
||||
.header {
|
||||
.ui.right {
|
||||
.search {
|
||||
input {
|
||||
font-weight: normal;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
}
|
||||
.button {
|
||||
float: right;
|
||||
margin-left: 5px;
|
||||
margin-top: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.commits.table {
|
||||
font-size: 13px;
|
||||
th, td {
|
||||
&:first-child {
|
||||
padding-left: 15px;
|
||||
}
|
||||
}
|
||||
td {
|
||||
line-height: 15px;
|
||||
}
|
||||
.author {
|
||||
min-width: 180px;
|
||||
}
|
||||
.sha {
|
||||
a {
|
||||
font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
|
||||
font-size: 14px;
|
||||
padding: 6px 10px 4px 10px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
.message span {
|
||||
max-width: 500px;
|
||||
}
|
||||
.date {
|
||||
width: 120px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ui.comments {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.user {
|
||||
padding-top: 15px;
|
||||
padding-bottom: @footer-margin * 3;
|
||||
padding-bottom: @footer-margin * 2;
|
||||
|
||||
&.settings {
|
||||
.key.list {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"path"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
"github.com/Unknwon/paginater"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
|
@ -44,7 +45,7 @@ func RenderIssueLinks(oldCommits *list.List, repoLink string) *list.List {
|
|||
}
|
||||
|
||||
func Commits(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
ctx.Data["PageIsCommits"] = true
|
||||
|
||||
userName := ctx.Repo.Owner.Name
|
||||
repoName := ctx.Repo.Repository.Name
|
||||
|
@ -64,19 +65,11 @@ func Commits(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// Calculate and validate page number.
|
||||
page, _ := com.StrTo(ctx.Query("p")).Int()
|
||||
if page < 1 {
|
||||
page := ctx.QueryInt("page")
|
||||
if page <= 1 {
|
||||
page = 1
|
||||
}
|
||||
lastPage := page - 1
|
||||
if lastPage < 0 {
|
||||
lastPage = 0
|
||||
}
|
||||
nextPage := page + 1
|
||||
if page*50 > commitsCount {
|
||||
nextPage = 0
|
||||
}
|
||||
ctx.Data["Page"] = paginater.New(commitsCount, git.CommitsRangeSize, page, 5)
|
||||
|
||||
// Both `git log branchName` and `git log commitId` work.
|
||||
commits, err := ctx.Repo.Commit.CommitsByRange(page)
|
||||
|
@ -91,14 +84,11 @@ func Commits(ctx *middleware.Context) {
|
|||
ctx.Data["Username"] = userName
|
||||
ctx.Data["Reponame"] = repoName
|
||||
ctx.Data["CommitCount"] = commitsCount
|
||||
ctx.Data["LastPageNum"] = lastPage
|
||||
ctx.Data["NextPageNum"] = nextPage
|
||||
ctx.HTML(200, COMMITS)
|
||||
}
|
||||
|
||||
func SearchCommits(ctx *middleware.Context) {
|
||||
ctx.Data["IsSearchPage"] = true
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
ctx.Data["PageIsCommits"] = true
|
||||
|
||||
keyword := ctx.Query("q")
|
||||
if len(keyword) == 0 {
|
||||
|
@ -253,7 +243,7 @@ func Diff(ctx *middleware.Context) {
|
|||
ctx.Data["Parents"] = parents
|
||||
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
||||
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitId)
|
||||
if (commit.ParentCount() > 0) {
|
||||
if commit.ParentCount() > 0 {
|
||||
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0])
|
||||
}
|
||||
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitId)
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
{{template "ng/base/head" .}}
|
||||
{{template "ng/base/header" .}}
|
||||
<div id="repo-wrapper">
|
||||
{{template "repo/header_old" .}}
|
||||
<div class="container clear">
|
||||
{{template "repo/commits_table" .}}
|
||||
</div>
|
||||
{{template "base/head" .}}
|
||||
<div class="repository commits">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container">
|
||||
{{template "repo/commits_table" .}}
|
||||
</div>
|
||||
</div>
|
||||
{{template "ng/base/footer" .}}
|
||||
{{template "base/footer" .}}
|
||||
|
|
|
@ -1,48 +1,66 @@
|
|||
<div id="commits-list">
|
||||
<div class="panel panel-radius">
|
||||
<div class="panel-header">
|
||||
{{if not .IsDiffCompare}}
|
||||
<form class="search pull-right" action="{{.RepoLink}}/commits/{{.BranchName}}/search" method="get" id="commits-search-form">
|
||||
<input class="ipt ipt-radius" type="search" name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" />
|
||||
<button class="btn btn-black btn-small btn-radius">{{.i18n.Tr "repo.commits.find"}}</button>
|
||||
</form>
|
||||
{{end}}
|
||||
<h4>{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}}</h4>
|
||||
</div>
|
||||
<table class="panel-body table commit-list table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="author">{{.i18n.Tr "repo.commits.author"}}</th>
|
||||
<th class="sha">SHA1</th>
|
||||
<th class="message">{{.i18n.Tr "repo.commits.message"}}</th>
|
||||
<th class="date">{{.i18n.Tr "repo.commits.date"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ $username := .Username}}
|
||||
{{ $reponame := .Reponame}}
|
||||
{{$r := List .Commits}}
|
||||
{{range $r}}
|
||||
<tr>
|
||||
<td class="author">
|
||||
{{if .User}}
|
||||
<img class="avatar-20" src="{{.User.AvatarLink}}" alt=""/> <a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
|
||||
{{else}}
|
||||
<img class="avatar-20" src="{{AvatarLink .Author.Email}}" alt=""/> {{.Author.Name}}
|
||||
{{end}}
|
||||
</td>
|
||||
<td class="sha"><a rel="nofollow" class="label label-green" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
||||
<td class="message"><span class="text-truncate">{{RenderCommitMessage .Summary $.RepoLink}}</span></td>
|
||||
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{if and (not .IsSearchPage) (not .IsDiffCompare)}}
|
||||
<ul class="pagination">
|
||||
{{if .LastPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.LastPageNum}}" rel="nofollow">« {{.i18n.Tr "repo.commits.newer"}}</a></li>{{end}}
|
||||
{{if .NextPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.NextPageNum}}" rel="nofollow">» {{.i18n.Tr "repo.commits.older"}}</a></li>{{end}}
|
||||
</ul>
|
||||
<h4 class="ui top attached header">
|
||||
{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}}
|
||||
{{if .PageIsCommits}}
|
||||
<div class="ui right">
|
||||
<form action="{{.RepoLink}}/commits/{{.BranchName}}/search">
|
||||
<div class="ui tiny search input">
|
||||
<input name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" autofocus>
|
||||
</div>
|
||||
<button class="ui black tiny button" data-panel="#add-deploy-key-panel">{{.i18n.Tr "repo.commits.find"}}</button>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
</h4>
|
||||
<div class="ui attached table segment">
|
||||
<table class="ui very basic striped commits table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{.i18n.Tr "repo.commits.author"}}</th>
|
||||
<th>SHA1</th>
|
||||
<th>{{.i18n.Tr "repo.commits.message"}}</th>
|
||||
<th>{{.i18n.Tr "repo.commits.date"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ $username := .Username}}
|
||||
{{ $reponame := .Reponame}}
|
||||
{{ $r:= List .Commits}}
|
||||
{{range $r}}
|
||||
<tr>
|
||||
<td class="author">
|
||||
{{if .User}}
|
||||
<img class="ui avatar image" src="{{.User.AvatarLink}}" alt=""/> <a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
|
||||
{{else}}
|
||||
<img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/> {{.Author.Name}}
|
||||
{{end}}
|
||||
</td>
|
||||
<td class="sha"><a rel="nofollow" class="ui green label" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
||||
<td class="message"><span class="text truncate">{{RenderCommitMessage .Summary $.RepoLink}}</span></td>
|
||||
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{{with .Page}}
|
||||
{{if gt .TotalPages 1}}
|
||||
<div class="center page buttons">
|
||||
<div class="ui borderless pagination menu">
|
||||
<a class="{{if not .HasPrevious}}disabled{{end}} item" {{if .HasPrevious}}href="{{$.RepoLink}}/commits/{{$.BranchName}}{{if $.FileName}}/{{$.FileName}}{{end}}?page={{.Previous}}"{{end}}>
|
||||
<i class="left arrow icon"></i> {{$.i18n.Tr "repo.issues.previous"}}
|
||||
</a>
|
||||
{{range .Pages}}
|
||||
{{if eq .Num -1}}
|
||||
<a class="disabled item">...</a>
|
||||
{{else}}
|
||||
<a class="{{if .IsCurrent}}active{{end}} item" {{if not .IsCurrent}}href="{{$.RepoLink}}/commits/{{$.BranchName}}{{if $.FileName}}/{{$.FileName}}{{end}}?page={{.Num}}"{{end}}>{{.Num}}</a>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<a class="{{if not .HasNext}}disabled{{end}} item" {{if .HasNext}}href="{{$.RepoLink}}/commits/{{$.BranchName}}{{if $.FileName}}/{{$.FileName}}{{end}}?page={{.Next}}"{{end}}>
|
||||
{{$.i18n.Tr "repo.issues.next"}} <i class="icon right arrow"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
|
@ -1,19 +1,18 @@
|
|||
{{template "ng/base/head" .}}
|
||||
{{template "ng/base/header" .}}
|
||||
<div id="repo-wrapper">
|
||||
{{template "repo/header_old" .}}
|
||||
<div class="container clear" id="diff-page">
|
||||
{{if .IsDiffCompare }}
|
||||
{{template "base/head" .}}
|
||||
<div class="repository diff">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container">
|
||||
{{if .IsDiffCompare }}
|
||||
<div class="panel panel-info panel-radius compare-head-box">
|
||||
<div class="panel-header">
|
||||
<a class="pull-right btn btn-blue btn-header btn-medium btn-radius" rel="nofollow" href="{{EscapePound .SourcePath}}">{{.i18n.Tr "repo.diff.browse_source"}}</a>
|
||||
<h4><a href="{{$.RepoLink}}/commit/{{.BeforeCommitId}}" class="label label-green">{{ShortSha .BeforeCommitId}}</a> ... <a href="{{$.RepoLink}}/commit/{{.AfterCommitId}}" class="label label-green">{{ShortSha .AfterCommitId}}</a></h4>
|
||||
</div>
|
||||
<div class="panel-body compare">
|
||||
{{template "repo/commits_table" .}}
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
{{template "repo/commits_table" .}}
|
||||
{{else}}
|
||||
<div class="panel panel-info panel-radius diff-head-box">
|
||||
<div class="panel-header">
|
||||
<a class="pull-right btn btn-blue btn-header btn-medium btn-radius" rel="nofollow" href="{{EscapePound .SourcePath}}">{{.i18n.Tr "repo.diff.browse_source"}}</a>
|
||||
|
@ -41,7 +40,8 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if .DiffNotAvailable}}
|
||||
<h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
|
||||
{{else}}
|
||||
|
@ -129,6 +129,6 @@
|
|||
<br>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{template "ng/base/footer" .}}
|
||||
{{template "base/footer" .}}
|
||||
|
|
Загрузка…
Ссылка в новой задаче