Replace list.List
with slices (#16311)
* Replaced list with slice. * Fixed usage of pointer to temporary variable. * Replaced LIFO list with slice. * Lint * Removed type check. * Removed duplicated code. * Lint * Fixed merge. Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
23d438f565
commit
d9ef43a712
29 changed files with 183 additions and 302 deletions
20
models/commit.go
Normal file
20
models/commit.go
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright 2021 Gitea. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.gitea.io/gitea/modules/git"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConvertFromGitCommit converts git commits into SignCommitWithStatuses
|
||||||
|
func ConvertFromGitCommit(commits []*git.Commit, repo *Repository) []*SignCommitWithStatuses {
|
||||||
|
return ParseCommitsWithStatus(
|
||||||
|
ParseCommitsWithSignature(
|
||||||
|
ValidateCommitsWithEmails(commits),
|
||||||
|
repo,
|
||||||
|
),
|
||||||
|
repo,
|
||||||
|
)
|
||||||
|
}
|
|
@ -5,7 +5,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -257,16 +256,12 @@ type SignCommitWithStatuses struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state
|
// ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state
|
||||||
func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List {
|
func ParseCommitsWithStatus(oldCommits []*SignCommit, repo *Repository) []*SignCommitWithStatuses {
|
||||||
var (
|
newCommits := make([]*SignCommitWithStatuses, 0, len(oldCommits))
|
||||||
newCommits = list.New()
|
|
||||||
e = oldCommits.Front()
|
|
||||||
)
|
|
||||||
|
|
||||||
for e != nil {
|
for _, c := range oldCommits {
|
||||||
c := e.Value.(SignCommit)
|
commit := &SignCommitWithStatuses{
|
||||||
commit := SignCommitWithStatuses{
|
SignCommit: c,
|
||||||
SignCommit: &c,
|
|
||||||
}
|
}
|
||||||
statuses, err := GetLatestCommitStatus(repo.ID, commit.ID.String(), ListOptions{})
|
statuses, err := GetLatestCommitStatus(repo.ID, commit.ID.String(), ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -276,8 +271,7 @@ func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List
|
||||||
commit.Status = CalcCommitStatus(statuses)
|
commit.Status = CalcCommitStatus(statuses)
|
||||||
}
|
}
|
||||||
|
|
||||||
newCommits.PushBack(commit)
|
newCommits = append(newCommits, commit)
|
||||||
e = e.Next()
|
|
||||||
}
|
}
|
||||||
return newCommits
|
return newCommits
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash"
|
"hash"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -68,24 +67,19 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseCommitsWithSignature checks if signaute of commits are corresponding to users gpg keys.
|
// ParseCommitsWithSignature checks if signaute of commits are corresponding to users gpg keys.
|
||||||
func ParseCommitsWithSignature(oldCommits *list.List, repository *Repository) *list.List {
|
func ParseCommitsWithSignature(oldCommits []*UserCommit, repository *Repository) []*SignCommit {
|
||||||
var (
|
newCommits := make([]*SignCommit, 0, len(oldCommits))
|
||||||
newCommits = list.New()
|
|
||||||
e = oldCommits.Front()
|
|
||||||
)
|
|
||||||
keyMap := map[string]bool{}
|
keyMap := map[string]bool{}
|
||||||
|
|
||||||
for e != nil {
|
for _, c := range oldCommits {
|
||||||
c := e.Value.(UserCommit)
|
signCommit := &SignCommit{
|
||||||
signCommit := SignCommit{
|
UserCommit: c,
|
||||||
UserCommit: &c,
|
|
||||||
Verification: ParseCommitWithSignature(c.Commit),
|
Verification: ParseCommitWithSignature(c.Commit),
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = CalculateTrustStatus(signCommit.Verification, repository, &keyMap)
|
_ = CalculateTrustStatus(signCommit.Verification, repository, &keyMap)
|
||||||
|
|
||||||
newCommits.PushBack(signCommit)
|
newCommits = append(newCommits, signCommit)
|
||||||
e = e.Next()
|
|
||||||
}
|
}
|
||||||
return newCommits
|
return newCommits
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -191,7 +190,7 @@ type Comment struct {
|
||||||
RefIssue *Issue `xorm:"-"`
|
RefIssue *Issue `xorm:"-"`
|
||||||
RefComment *Comment `xorm:"-"`
|
RefComment *Comment `xorm:"-"`
|
||||||
|
|
||||||
Commits *list.List `xorm:"-"`
|
Commits []*SignCommitWithStatuses `xorm:"-"`
|
||||||
OldCommit string `xorm:"-"`
|
OldCommit string `xorm:"-"`
|
||||||
NewCommit string `xorm:"-"`
|
NewCommit string `xorm:"-"`
|
||||||
CommitsNum int64 `xorm:"-"`
|
CommitsNum int64 `xorm:"-"`
|
||||||
|
@ -675,13 +674,8 @@ func (c *Comment) LoadPushCommits() (err error) {
|
||||||
}
|
}
|
||||||
defer gitRepo.Close()
|
defer gitRepo.Close()
|
||||||
|
|
||||||
c.Commits = gitRepo.GetCommitsFromIDs(data.CommitIDs)
|
c.Commits = ConvertFromGitCommit(gitRepo.GetCommitsFromIDs(data.CommitIDs), c.Issue.Repo)
|
||||||
c.CommitsNum = int64(c.Commits.Len())
|
c.CommitsNum = int64(len(c.Commits))
|
||||||
if c.CommitsNum > 0 {
|
|
||||||
c.Commits = ValidateCommitsWithEmails(c.Commits)
|
|
||||||
c.Commits = ParseCommitsWithSignature(c.Commits, c.Issue.Repo)
|
|
||||||
c.Commits = ParseCommitsWithStatus(c.Commits, c.Issue.Repo)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
@ -1293,21 +1287,17 @@ func getCommitIDsFromRepo(repo *Repository, oldCommitID, newCommitID, baseBranch
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
commits, err := newCommit.CommitsBeforeUntil(oldCommitID)
|
||||||
commits *list.List
|
|
||||||
commitChecks map[string]commitBranchCheckItem
|
|
||||||
)
|
|
||||||
commits, err = newCommit.CommitsBeforeUntil(oldCommitID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
commitIDs = make([]string, 0, commits.Len())
|
commitIDs = make([]string, 0, len(commits))
|
||||||
commitChecks = make(map[string]commitBranchCheckItem)
|
commitChecks := make(map[string]*commitBranchCheckItem)
|
||||||
|
|
||||||
for e := commits.Front(); e != nil; e = e.Next() {
|
for _, commit := range commits {
|
||||||
commitChecks[e.Value.(*git.Commit).ID.String()] = commitBranchCheckItem{
|
commitChecks[commit.ID.String()] = &commitBranchCheckItem{
|
||||||
Commit: e.Value.(*git.Commit),
|
Commit: commit,
|
||||||
Checked: false,
|
Checked: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1316,8 +1306,8 @@ func getCommitIDsFromRepo(repo *Repository, oldCommitID, newCommitID, baseBranch
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for e := commits.Back(); e != nil; e = e.Prev() {
|
for i := len(commits) - 1; i >= 0; i-- {
|
||||||
commitID := e.Value.(*git.Commit).ID.String()
|
commitID := commits[i].ID.String()
|
||||||
if item, ok := commitChecks[commitID]; ok && item.Checked {
|
if item, ok := commitChecks[commitID]; ok && item.Checked {
|
||||||
commitIDs = append(commitIDs, commitID)
|
commitIDs = append(commitIDs, commitID)
|
||||||
}
|
}
|
||||||
|
@ -1331,64 +1321,49 @@ type commitBranchCheckItem struct {
|
||||||
Checked bool
|
Checked bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func commitBranchCheck(gitRepo *git.Repository, startCommit *git.Commit, endCommitID, baseBranch string, commitList map[string]commitBranchCheckItem) (err error) {
|
func commitBranchCheck(gitRepo *git.Repository, startCommit *git.Commit, endCommitID, baseBranch string, commitList map[string]*commitBranchCheckItem) error {
|
||||||
var (
|
|
||||||
item commitBranchCheckItem
|
|
||||||
ok bool
|
|
||||||
listItem *list.Element
|
|
||||||
tmp string
|
|
||||||
)
|
|
||||||
|
|
||||||
if startCommit.ID.String() == endCommitID {
|
if startCommit.ID.String() == endCommitID {
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
checkStack := list.New()
|
checkStack := make([]string, 0, 10)
|
||||||
checkStack.PushBack(startCommit.ID.String())
|
checkStack = append(checkStack, startCommit.ID.String())
|
||||||
listItem = checkStack.Back()
|
|
||||||
|
|
||||||
for listItem != nil {
|
for len(checkStack) > 0 {
|
||||||
tmp = listItem.Value.(string)
|
commitID := checkStack[0]
|
||||||
checkStack.Remove(listItem)
|
checkStack = checkStack[1:]
|
||||||
|
|
||||||
if item, ok = commitList[tmp]; !ok {
|
item, ok := commitList[commitID]
|
||||||
listItem = checkStack.Back()
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.Commit.ID.String() == endCommitID {
|
if item.Commit.ID.String() == endCommitID {
|
||||||
listItem = checkStack.Back()
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = item.Commit.LoadBranchName(); err != nil {
|
if err := item.Commit.LoadBranchName(); err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.Commit.Branch == baseBranch {
|
if item.Commit.Branch == baseBranch {
|
||||||
listItem = checkStack.Back()
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.Checked {
|
if item.Checked {
|
||||||
listItem = checkStack.Back()
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
item.Checked = true
|
item.Checked = true
|
||||||
commitList[tmp] = item
|
|
||||||
|
|
||||||
parentNum := item.Commit.ParentCount()
|
parentNum := item.Commit.ParentCount()
|
||||||
for i := 0; i < parentNum; i++ {
|
for i := 0; i < parentNum; i++ {
|
||||||
var parentCommit *git.Commit
|
parentCommit, err := item.Commit.Parent(i)
|
||||||
parentCommit, err = item.Commit.Parent(i)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
checkStack.PushBack(parentCommit.ID.String())
|
checkStack = append(checkStack, parentCommit.ID.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
listItem = checkStack.Back()
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,8 +118,7 @@ Loop:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", nil, err
|
return false, "", nil, err
|
||||||
}
|
}
|
||||||
for e := commitList.Front(); e != nil; e = e.Next() {
|
for _, commit := range commitList {
|
||||||
commit = e.Value.(*git.Commit)
|
|
||||||
verification := ParseCommitWithSignature(commit)
|
verification := ParseCommitWithSignature(commit)
|
||||||
if !verification.Verified {
|
if !verification.Verified {
|
||||||
return false, "", nil, &ErrWontSign{commitsSigned}
|
return false, "", nil, &ErrWontSign{commitsSigned}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"crypto/subtle"
|
"crypto/subtle"
|
||||||
|
@ -1509,16 +1508,13 @@ func ValidateCommitWithEmail(c *git.Commit) *User {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
|
// ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
|
||||||
func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
|
func ValidateCommitsWithEmails(oldCommits []*git.Commit) []*UserCommit {
|
||||||
var (
|
var (
|
||||||
u *User
|
emails = make(map[string]*User)
|
||||||
emails = map[string]*User{}
|
newCommits = make([]*UserCommit, 0, len(oldCommits))
|
||||||
newCommits = list.New()
|
|
||||||
e = oldCommits.Front()
|
|
||||||
)
|
)
|
||||||
for e != nil {
|
for _, c := range oldCommits {
|
||||||
c := e.Value.(*git.Commit)
|
var u *User
|
||||||
|
|
||||||
if c.Author != nil {
|
if c.Author != nil {
|
||||||
if v, ok := emails[c.Author.Email]; !ok {
|
if v, ok := emails[c.Author.Email]; !ok {
|
||||||
u, _ = GetUserByEmail(c.Author.Email)
|
u, _ = GetUserByEmail(c.Author.Email)
|
||||||
|
@ -1526,15 +1522,12 @@ func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
|
||||||
} else {
|
} else {
|
||||||
u = v
|
u = v
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
u = nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newCommits.PushBack(UserCommit{
|
newCommits = append(newCommits, &UserCommit{
|
||||||
User: u,
|
User: u,
|
||||||
Commit: c,
|
Commit: c,
|
||||||
})
|
})
|
||||||
e = e.Next()
|
|
||||||
}
|
}
|
||||||
return newCommits
|
return newCommits
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ package git
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"container/list"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -187,12 +186,12 @@ func (c *Commit) CommitsCount() (int64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsByRange returns the specific page commits before current revision, every page's number default by CommitsRangeSize
|
// CommitsByRange returns the specific page commits before current revision, every page's number default by CommitsRangeSize
|
||||||
func (c *Commit) CommitsByRange(page, pageSize int) (*list.List, error) {
|
func (c *Commit) CommitsByRange(page, pageSize int) ([]*Commit, error) {
|
||||||
return c.repo.commitsByRange(c.ID, page, pageSize)
|
return c.repo.commitsByRange(c.ID, page, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsBefore returns all the commits before current revision
|
// CommitsBefore returns all the commits before current revision
|
||||||
func (c *Commit) CommitsBefore() (*list.List, error) {
|
func (c *Commit) CommitsBefore() ([]*Commit, error) {
|
||||||
return c.repo.getCommitsBefore(c.ID)
|
return c.repo.getCommitsBefore(c.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,12 +227,12 @@ func (c *Commit) HasPreviousCommit(commitHash SHA1) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsBeforeLimit returns num commits before current revision
|
// CommitsBeforeLimit returns num commits before current revision
|
||||||
func (c *Commit) CommitsBeforeLimit(num int) (*list.List, error) {
|
func (c *Commit) CommitsBeforeLimit(num int) ([]*Commit, error) {
|
||||||
return c.repo.getCommitsBeforeLimit(c.ID, num)
|
return c.repo.getCommitsBeforeLimit(c.ID, num)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsBeforeUntil returns the commits between commitID to current revision
|
// CommitsBeforeUntil returns the commits between commitID to current revision
|
||||||
func (c *Commit) CommitsBeforeUntil(commitID string) (*list.List, error) {
|
func (c *Commit) CommitsBeforeUntil(commitID string) ([]*Commit, error) {
|
||||||
endCommit, err := c.repo.GetCommit(commitID)
|
endCommit, err := c.repo.GetCommit(commitID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -281,7 +280,7 @@ func NewSearchCommitsOptions(searchString string, forAllRefs bool) SearchCommits
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchCommits returns the commits match the keyword before current revision
|
// SearchCommits returns the commits match the keyword before current revision
|
||||||
func (c *Commit) SearchCommits(opts SearchCommitsOptions) (*list.List, error) {
|
func (c *Commit) SearchCommits(opts SearchCommitsOptions) ([]*Commit, error) {
|
||||||
return c.repo.searchCommits(c.ID, opts)
|
return c.repo.searchCommits(c.ID, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"container/list"
|
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
@ -33,10 +32,10 @@ func (repo *Repository) GetAllCommitsCount() (int64, error) {
|
||||||
return AllCommitsCount(repo.Path, false)
|
return AllCommitsCount(repo.Path, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) parsePrettyFormatLogToList(logs []byte) (*list.List, error) {
|
func (repo *Repository) parsePrettyFormatLogToList(logs []byte) ([]*Commit, error) {
|
||||||
l := list.New()
|
var commits []*Commit
|
||||||
if len(logs) == 0 {
|
if len(logs) == 0 {
|
||||||
return l, nil
|
return commits, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
parts := bytes.Split(logs, []byte{'\n'})
|
parts := bytes.Split(logs, []byte{'\n'})
|
||||||
|
@ -46,10 +45,10 @@ func (repo *Repository) parsePrettyFormatLogToList(logs []byte) (*list.List, err
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
l.PushBack(commit)
|
commits = append(commits, commit)
|
||||||
}
|
}
|
||||||
|
|
||||||
return l, nil
|
return commits, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsRepoURLAccessible checks if given repository URL is accessible.
|
// IsRepoURLAccessible checks if given repository URL is accessible.
|
||||||
|
|
|
@ -7,7 +7,6 @@ package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"container/list"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -84,10 +83,10 @@ func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return commits.Front().Value.(*Commit), nil
|
return commits[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) commitsByRange(id SHA1, page, pageSize int) (*list.List, error) {
|
func (repo *Repository) commitsByRange(id SHA1, page, pageSize int) ([]*Commit, error) {
|
||||||
stdout, err := NewCommand("log", id.String(), "--skip="+strconv.Itoa((page-1)*pageSize),
|
stdout, err := NewCommand("log", id.String(), "--skip="+strconv.Itoa((page-1)*pageSize),
|
||||||
"--max-count="+strconv.Itoa(pageSize), prettyLogFormat).RunInDirBytes(repo.Path)
|
"--max-count="+strconv.Itoa(pageSize), prettyLogFormat).RunInDirBytes(repo.Path)
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ func (repo *Repository) commitsByRange(id SHA1, page, pageSize int) (*list.List,
|
||||||
return repo.parsePrettyFormatLogToList(stdout)
|
return repo.parsePrettyFormatLogToList(stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) searchCommits(id SHA1, opts SearchCommitsOptions) (*list.List, error) {
|
func (repo *Repository) searchCommits(id SHA1, opts SearchCommitsOptions) ([]*Commit, error) {
|
||||||
// create new git log command with limit of 100 commis
|
// create new git log command with limit of 100 commis
|
||||||
cmd := NewCommand("log", id.String(), "-100", prettyLogFormat)
|
cmd := NewCommand("log", id.String(), "-100", prettyLogFormat)
|
||||||
// ignore case
|
// ignore case
|
||||||
|
@ -201,7 +200,7 @@ func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsByFileAndRange return the commits according revision file and the page
|
// CommitsByFileAndRange return the commits according revision file and the page
|
||||||
func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) {
|
func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) ([]*Commit, error) {
|
||||||
skip := (page - 1) * setting.Git.CommitsRangeSize
|
skip := (page - 1) * setting.Git.CommitsRangeSize
|
||||||
|
|
||||||
stdoutReader, stdoutWriter := io.Pipe()
|
stdoutReader, stdoutWriter := io.Pipe()
|
||||||
|
@ -226,7 +225,7 @@ func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (
|
||||||
_, err := io.CopyN(ioutil.Discard, stdoutReader, int64(skip*41))
|
_, err := io.CopyN(ioutil.Discard, stdoutReader, int64(skip*41))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
return list.New(), nil
|
return []*Commit{}, nil
|
||||||
}
|
}
|
||||||
_ = stdoutReader.CloseWithError(err)
|
_ = stdoutReader.CloseWithError(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -241,7 +240,7 @@ func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsByFileAndRangeNoFollow return the commits according revision file and the page
|
// CommitsByFileAndRangeNoFollow return the commits according revision file and the page
|
||||||
func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page int) (*list.List, error) {
|
func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page int) ([]*Commit, error) {
|
||||||
stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*50),
|
stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*50),
|
||||||
"--max-count="+strconv.Itoa(setting.Git.CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path)
|
"--max-count="+strconv.Itoa(setting.Git.CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -266,7 +265,7 @@ func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (in
|
||||||
|
|
||||||
// CommitsBetween returns a list that contains commits between [before, last).
|
// CommitsBetween returns a list that contains commits between [before, last).
|
||||||
// If before is detached (removed by reset + push) it is not included.
|
// If before is detached (removed by reset + push) it is not included.
|
||||||
func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error) {
|
func (repo *Repository) CommitsBetween(last *Commit, before *Commit) ([]*Commit, error) {
|
||||||
var stdout []byte
|
var stdout []byte
|
||||||
var err error
|
var err error
|
||||||
if before == nil {
|
if before == nil {
|
||||||
|
@ -286,7 +285,7 @@ func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [before, last)
|
// CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [before, last)
|
||||||
func (repo *Repository) CommitsBetweenLimit(last *Commit, before *Commit, limit, skip int) (*list.List, error) {
|
func (repo *Repository) CommitsBetweenLimit(last *Commit, before *Commit, limit, skip int) ([]*Commit, error) {
|
||||||
var stdout []byte
|
var stdout []byte
|
||||||
var err error
|
var err error
|
||||||
if before == nil {
|
if before == nil {
|
||||||
|
@ -306,7 +305,7 @@ func (repo *Repository) CommitsBetweenLimit(last *Commit, before *Commit, limit,
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsBetweenIDs return commits between twoe commits
|
// CommitsBetweenIDs return commits between twoe commits
|
||||||
func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, error) {
|
func (repo *Repository) CommitsBetweenIDs(last, before string) ([]*Commit, error) {
|
||||||
lastCommit, err := repo.GetCommit(last)
|
lastCommit, err := repo.GetCommit(last)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -334,7 +333,7 @@ func (repo *Repository) CommitsCountBetween(start, end string) (int64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// commitsBefore the limit is depth, not total number of returned commits.
|
// commitsBefore the limit is depth, not total number of returned commits.
|
||||||
func (repo *Repository) commitsBefore(id SHA1, limit int) (*list.List, error) {
|
func (repo *Repository) commitsBefore(id SHA1, limit int) ([]*Commit, error) {
|
||||||
cmd := NewCommand("log")
|
cmd := NewCommand("log")
|
||||||
if limit > 0 {
|
if limit > 0 {
|
||||||
cmd.AddArguments("-"+strconv.Itoa(limit), prettyLogFormat, id.String())
|
cmd.AddArguments("-"+strconv.Itoa(limit), prettyLogFormat, id.String())
|
||||||
|
@ -352,9 +351,8 @@ func (repo *Repository) commitsBefore(id SHA1, limit int) (*list.List, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
commits := list.New()
|
commits := make([]*Commit, 0, len(formattedLog))
|
||||||
for logEntry := formattedLog.Front(); logEntry != nil; logEntry = logEntry.Next() {
|
for _, commit := range formattedLog {
|
||||||
commit := logEntry.Value.(*Commit)
|
|
||||||
branches, err := repo.getBranches(commit, 2)
|
branches, err := repo.getBranches(commit, 2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -364,17 +362,17 @@ func (repo *Repository) commitsBefore(id SHA1, limit int) (*list.List, error) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
commits.PushBack(commit)
|
commits = append(commits, commit)
|
||||||
}
|
}
|
||||||
|
|
||||||
return commits, nil
|
return commits, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) getCommitsBefore(id SHA1) (*list.List, error) {
|
func (repo *Repository) getCommitsBefore(id SHA1) ([]*Commit, error) {
|
||||||
return repo.commitsBefore(id, 0)
|
return repo.commitsBefore(id, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) getCommitsBeforeLimit(id SHA1, num int) (*list.List, error) {
|
func (repo *Repository) getCommitsBeforeLimit(id SHA1, num int) ([]*Commit, error) {
|
||||||
return repo.commitsBefore(id, num)
|
return repo.commitsBefore(id, num)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,13 +411,13 @@ func (repo *Repository) getBranches(commit *Commit, limit int) ([]string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCommitsFromIDs get commits from commit IDs
|
// GetCommitsFromIDs get commits from commit IDs
|
||||||
func (repo *Repository) GetCommitsFromIDs(commitIDs []string) (commits *list.List) {
|
func (repo *Repository) GetCommitsFromIDs(commitIDs []string) []*Commit {
|
||||||
commits = list.New()
|
commits := make([]*Commit, 0, len(commitIDs))
|
||||||
|
|
||||||
for _, commitID := range commitIDs {
|
for _, commitID := range commitIDs {
|
||||||
commit, err := repo.GetCommit(commitID)
|
commit, err := repo.GetCommit(commitID)
|
||||||
if err == nil && commit != nil {
|
if err == nil && commit != nil {
|
||||||
commits.PushBack(commit)
|
commits = append(commits, commit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,6 @@ func TestRepository_CommitsBetweenIDs(t *testing.T) {
|
||||||
for i, c := range cases {
|
for i, c := range cases {
|
||||||
commits, err := bareRepo1.CommitsBetweenIDs(c.NewID, c.OldID)
|
commits, err := bareRepo1.CommitsBetweenIDs(c.NewID, c.OldID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, c.ExpectedCommits, commits.Len(), "case %d", i)
|
assert.Equal(t, c.ExpectedCommits, len(commits), "case %d", i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"container/list"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -23,7 +22,7 @@ type CompareInfo struct {
|
||||||
MergeBase string
|
MergeBase string
|
||||||
BaseCommitID string
|
BaseCommitID string
|
||||||
HeadCommitID string
|
HeadCommitID string
|
||||||
Commits *list.List
|
Commits []*Commit
|
||||||
NumFiles int
|
NumFiles int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +89,7 @@ func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string)
|
||||||
return nil, fmt.Errorf("parsePrettyFormatLogToList: %v", err)
|
return nil, fmt.Errorf("parsePrettyFormatLogToList: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
compareInfo.Commits = list.New()
|
compareInfo.Commits = []*Commit{}
|
||||||
compareInfo.MergeBase, err = GetFullCommitID(repo.Path, remoteBranch)
|
compareInfo.MergeBase, err = GetFullCommitID(repo.Path, remoteBranch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
compareInfo.MergeBase = remoteBranch
|
compareInfo.MergeBase = remoteBranch
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -175,12 +174,11 @@ func CommitToPushCommit(commit *git.Commit) *PushCommit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListToPushCommits transforms a list.List to PushCommits type.
|
// GitToPushCommits transforms a list of git.Commits to PushCommits type.
|
||||||
func ListToPushCommits(l *list.List) *PushCommits {
|
func GitToPushCommits(gitCommits []*git.Commit) *PushCommits {
|
||||||
var commits []*PushCommit
|
commits := make([]*PushCommit, 0, len(gitCommits))
|
||||||
for e := l.Front(); e != nil; e = e.Next() {
|
for _, commit := range gitCommits {
|
||||||
commit := CommitToPushCommit(e.Value.(*git.Commit))
|
commits = append(commits, CommitToPushCommit(commit))
|
||||||
commits = append(commits, commit)
|
|
||||||
}
|
}
|
||||||
return &PushCommits{commits, nil, "", make(map[string]string), make(map[string]*models.User)}
|
return &PushCommits{commits, nil, "", make(map[string]string), make(map[string]*models.User)}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -173,21 +172,22 @@ func TestListToPushCommits(t *testing.T) {
|
||||||
hash2, err := git.NewIDFromString(hexString2)
|
hash2, err := git.NewIDFromString(hexString2)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
l := list.New()
|
l := []*git.Commit{
|
||||||
l.PushBack(&git.Commit{
|
{
|
||||||
ID: hash1,
|
ID: hash1,
|
||||||
Author: sig,
|
Author: sig,
|
||||||
Committer: sig,
|
Committer: sig,
|
||||||
CommitMessage: "Message1",
|
CommitMessage: "Message1",
|
||||||
})
|
},
|
||||||
l.PushBack(&git.Commit{
|
{
|
||||||
ID: hash2,
|
ID: hash2,
|
||||||
Author: sig,
|
Author: sig,
|
||||||
Committer: sig,
|
Committer: sig,
|
||||||
CommitMessage: "Message2",
|
CommitMessage: "Message2",
|
||||||
})
|
},
|
||||||
|
}
|
||||||
|
|
||||||
pushCommits := ListToPushCommits(l)
|
pushCommits := GitToPushCommits(l)
|
||||||
if assert.Len(t, pushCommits.Commits, 2) {
|
if assert.Len(t, pushCommits.Commits, 2) {
|
||||||
assert.Equal(t, "Message1", pushCommits.Commits[0].Message)
|
assert.Equal(t, "Message1", pushCommits.Commits[0].Message)
|
||||||
assert.Equal(t, hexString1, pushCommits.Commits[0].Sha1)
|
assert.Equal(t, hexString1, pushCommits.Commits[0].Sha1)
|
||||||
|
|
|
@ -7,7 +7,6 @@ package templates
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"container/list"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
|
@ -126,7 +125,6 @@ func NewFuncMap() []template.FuncMap {
|
||||||
},
|
},
|
||||||
"SizeFmt": base.FileSize,
|
"SizeFmt": base.FileSize,
|
||||||
"CountFmt": base.FormatNumberSI,
|
"CountFmt": base.FormatNumberSI,
|
||||||
"List": List,
|
|
||||||
"SubStr": func(str string, start, length int) string {
|
"SubStr": func(str string, start, length int) string {
|
||||||
if len(str) == 0 {
|
if len(str) == 0 {
|
||||||
return ""
|
return ""
|
||||||
|
@ -297,18 +295,6 @@ func NewFuncMap() []template.FuncMap {
|
||||||
},
|
},
|
||||||
"CommentMustAsDiff": gitdiff.CommentMustAsDiff,
|
"CommentMustAsDiff": gitdiff.CommentMustAsDiff,
|
||||||
"MirrorRemoteAddress": mirrorRemoteAddress,
|
"MirrorRemoteAddress": mirrorRemoteAddress,
|
||||||
"CommitType": func(commit interface{}) string {
|
|
||||||
switch commit.(type) {
|
|
||||||
case models.SignCommitWithStatuses:
|
|
||||||
return "SignCommitWithStatuses"
|
|
||||||
case models.SignCommit:
|
|
||||||
return "SignCommit"
|
|
||||||
case models.UserCommit:
|
|
||||||
return "UserCommit"
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"NotificationSettings": func() map[string]interface{} {
|
"NotificationSettings": func() map[string]interface{} {
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond),
|
"MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond),
|
||||||
|
@ -428,7 +414,6 @@ func NewTextFuncMap() []texttmpl.FuncMap {
|
||||||
"DateFmtShort": func(t time.Time) string {
|
"DateFmtShort": func(t time.Time) string {
|
||||||
return t.Format("Jan 02, 2006")
|
return t.Format("Jan 02, 2006")
|
||||||
},
|
},
|
||||||
"List": List,
|
|
||||||
"SubStr": func(str string, start, length int) string {
|
"SubStr": func(str string, start, length int) string {
|
||||||
if len(str) == 0 {
|
if len(str) == 0 {
|
||||||
return ""
|
return ""
|
||||||
|
@ -636,20 +621,6 @@ func JSEscape(raw string) string {
|
||||||
return template.JSEscapeString(raw)
|
return template.JSEscapeString(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
// List traversings the list
|
|
||||||
func List(l *list.List) chan interface{} {
|
|
||||||
e := l.Front()
|
|
||||||
c := make(chan interface{})
|
|
||||||
go func() {
|
|
||||||
for e != nil {
|
|
||||||
c <- e.Value
|
|
||||||
e = e.Next()
|
|
||||||
}
|
|
||||||
close(c)
|
|
||||||
}()
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sha1 returns sha1 sum of string
|
// Sha1 returns sha1 sum of string
|
||||||
func Sha1(str string) string {
|
func Sha1(str string) string {
|
||||||
return base.EncodeSha1(str)
|
return base.EncodeSha1(str)
|
||||||
|
|
|
@ -190,20 +190,14 @@ func GetAllCommits(ctx *context.APIContext) {
|
||||||
|
|
||||||
userCache := make(map[string]*models.User)
|
userCache := make(map[string]*models.User)
|
||||||
|
|
||||||
apiCommits := make([]*api.Commit, commits.Len())
|
apiCommits := make([]*api.Commit, len(commits))
|
||||||
|
for i, commit := range commits {
|
||||||
i := 0
|
|
||||||
for commitPointer := commits.Front(); commitPointer != nil; commitPointer = commitPointer.Next() {
|
|
||||||
commit := commitPointer.Value.(*git.Commit)
|
|
||||||
|
|
||||||
// Create json struct
|
// Create json struct
|
||||||
apiCommits[i], err = convert.ToCommit(ctx.Repo.Repository, commit, userCache)
|
apiCommits[i], err = convert.ToCommit(ctx.Repo.Repository, commit, userCache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "toCommit", err)
|
ctx.Error(http.StatusInternalServerError, "toCommit", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// kept for backwards compatibility
|
// kept for backwards compatibility
|
||||||
|
|
|
@ -1211,7 +1211,7 @@ func GetPullRequestCommits(ctx *context.APIContext) {
|
||||||
|
|
||||||
listOptions := utils.GetListOptions(ctx)
|
listOptions := utils.GetListOptions(ctx)
|
||||||
|
|
||||||
totalNumberOfCommits := commits.Len()
|
totalNumberOfCommits := len(commits)
|
||||||
totalNumberOfPages := int(math.Ceil(float64(totalNumberOfCommits) / float64(listOptions.PageSize)))
|
totalNumberOfPages := int(math.Ceil(float64(totalNumberOfCommits) / float64(listOptions.PageSize)))
|
||||||
|
|
||||||
userCache := make(map[string]*models.User)
|
userCache := make(map[string]*models.User)
|
||||||
|
@ -1222,29 +1222,14 @@ func GetPullRequestCommits(ctx *context.APIContext) {
|
||||||
end = totalNumberOfCommits
|
end = totalNumberOfCommits
|
||||||
}
|
}
|
||||||
|
|
||||||
apiCommits := make([]*api.Commit, end-start)
|
apiCommits := make([]*api.Commit, 0, end-start)
|
||||||
|
for i := start; i < end; i++ {
|
||||||
i := 0
|
apiCommit, err := convert.ToCommit(ctx.Repo.Repository, commits[i], userCache)
|
||||||
addedCommitsCount := 0
|
|
||||||
for commitPointer := commits.Front(); commitPointer != nil; commitPointer = commitPointer.Next() {
|
|
||||||
if i < start {
|
|
||||||
i++
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if i >= end {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
commit := commitPointer.Value.(*git.Commit)
|
|
||||||
|
|
||||||
// Create json struct
|
|
||||||
apiCommits[addedCommitsCount], err = convert.ToCommit(ctx.Repo.Repository, commit, userCache)
|
|
||||||
addedCommitsCount++
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("toCommit", err)
|
ctx.ServerError("toCommit", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
i++
|
apiCommits = append(apiCommits, apiCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetLinkHeader(int(totalNumberOfCommits), listOptions.PageSize)
|
ctx.SetLinkHeader(int(totalNumberOfCommits), listOptions.PageSize)
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
gotemplate "html/template"
|
gotemplate "html/template"
|
||||||
|
@ -138,15 +137,15 @@ func RefBlame(ctx *context.Context) {
|
||||||
ctx.HTML(http.StatusOK, tplBlame)
|
ctx.HTML(http.StatusOK, tplBlame)
|
||||||
}
|
}
|
||||||
|
|
||||||
func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]models.UserCommit, map[string]string) {
|
func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]*models.UserCommit, map[string]string) {
|
||||||
// store commit data by SHA to look up avatar info etc
|
// store commit data by SHA to look up avatar info etc
|
||||||
commitNames := make(map[string]models.UserCommit)
|
commitNames := make(map[string]*models.UserCommit)
|
||||||
// previousCommits contains links from SHA to parent SHA,
|
// previousCommits contains links from SHA to parent SHA,
|
||||||
// if parent also contains the current TreePath.
|
// if parent also contains the current TreePath.
|
||||||
previousCommits := make(map[string]string)
|
previousCommits := make(map[string]string)
|
||||||
// and as blameParts can reference the same commits multiple
|
// and as blameParts can reference the same commits multiple
|
||||||
// times, we cache the lookup work locally
|
// times, we cache the lookup work locally
|
||||||
commits := list.New()
|
commits := make([]*git.Commit, 0, len(blameParts))
|
||||||
commitCache := map[string]*git.Commit{}
|
commitCache := map[string]*git.Commit{}
|
||||||
commitCache[ctx.Repo.Commit.ID.String()] = ctx.Repo.Commit
|
commitCache[ctx.Repo.Commit.ID.String()] = ctx.Repo.Commit
|
||||||
|
|
||||||
|
@ -190,22 +189,18 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commits.PushBack(commit)
|
commits = append(commits, commit)
|
||||||
|
|
||||||
commitNames[commit.ID.String()] = models.UserCommit{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// populate commit email addresses to later look up avatars.
|
// populate commit email addresses to later look up avatars.
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
for _, c := range models.ValidateCommitsWithEmails(commits) {
|
||||||
for e := commits.Front(); e != nil; e = e.Next() {
|
|
||||||
c := e.Value.(models.UserCommit)
|
|
||||||
commitNames[c.ID.String()] = c
|
commitNames[c.ID.String()] = c
|
||||||
}
|
}
|
||||||
|
|
||||||
return commitNames, previousCommits
|
return commitNames, previousCommits
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]models.UserCommit, previousCommits map[string]string) {
|
func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]*models.UserCommit, previousCommits map[string]string) {
|
||||||
repoLink := ctx.Repo.RepoLink
|
repoLink := ctx.Repo.RepoLink
|
||||||
|
|
||||||
var lines = make([]string, 0)
|
var lines = make([]string, 0)
|
||||||
|
|
|
@ -72,10 +72,7 @@ func Commits(ctx *context.Context) {
|
||||||
ctx.ServerError("CommitsByRange", err)
|
ctx.ServerError("CommitsByRange", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
ctx.Data["Commits"] = models.ConvertFromGitCommit(commits, ctx.Repo.Repository)
|
||||||
commits = models.ParseCommitsWithSignature(commits, ctx.Repo.Repository)
|
|
||||||
commits = models.ParseCommitsWithStatus(commits, ctx.Repo.Repository)
|
|
||||||
ctx.Data["Commits"] = commits
|
|
||||||
|
|
||||||
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
||||||
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
||||||
|
@ -193,10 +190,8 @@ func SearchCommits(ctx *context.Context) {
|
||||||
ctx.ServerError("SearchCommits", err)
|
ctx.ServerError("SearchCommits", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
ctx.Data["CommitCount"] = len(commits)
|
||||||
commits = models.ParseCommitsWithSignature(commits, ctx.Repo.Repository)
|
ctx.Data["Commits"] = models.ConvertFromGitCommit(commits, ctx.Repo.Repository)
|
||||||
commits = models.ParseCommitsWithStatus(commits, ctx.Repo.Repository)
|
|
||||||
ctx.Data["Commits"] = commits
|
|
||||||
|
|
||||||
ctx.Data["Keyword"] = query
|
ctx.Data["Keyword"] = query
|
||||||
if all {
|
if all {
|
||||||
|
@ -204,7 +199,6 @@ func SearchCommits(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
||||||
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
||||||
ctx.Data["CommitCount"] = commits.Len()
|
|
||||||
ctx.Data["Branch"] = ctx.Repo.BranchName
|
ctx.Data["Branch"] = ctx.Repo.BranchName
|
||||||
ctx.HTML(http.StatusOK, tplCommits)
|
ctx.HTML(http.StatusOK, tplCommits)
|
||||||
}
|
}
|
||||||
|
@ -239,10 +233,7 @@ func FileHistory(ctx *context.Context) {
|
||||||
ctx.ServerError("CommitsByFileAndRange", err)
|
ctx.ServerError("CommitsByFileAndRange", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
ctx.Data["Commits"] = models.ConvertFromGitCommit(commits, ctx.Repo.Repository)
|
||||||
commits = models.ParseCommitsWithSignature(commits, ctx.Repo.Repository)
|
|
||||||
commits = models.ParseCommitsWithStatus(commits, ctx.Repo.Repository)
|
|
||||||
ctx.Data["Commits"] = commits
|
|
||||||
|
|
||||||
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
||||||
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
||||||
|
|
|
@ -551,14 +551,12 @@ func PrepareCompareDiff(
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
compareInfo.Commits = models.ValidateCommitsWithEmails(compareInfo.Commits)
|
commits := models.ConvertFromGitCommit(compareInfo.Commits, headRepo)
|
||||||
compareInfo.Commits = models.ParseCommitsWithSignature(compareInfo.Commits, headRepo)
|
ctx.Data["Commits"] = commits
|
||||||
compareInfo.Commits = models.ParseCommitsWithStatus(compareInfo.Commits, headRepo)
|
ctx.Data["CommitCount"] = len(commits)
|
||||||
ctx.Data["Commits"] = compareInfo.Commits
|
|
||||||
ctx.Data["CommitCount"] = compareInfo.Commits.Len()
|
|
||||||
|
|
||||||
if compareInfo.Commits.Len() == 1 {
|
if len(commits) == 1 {
|
||||||
c := compareInfo.Commits.Front().Value.(models.SignCommitWithStatuses)
|
c := commits[0]
|
||||||
title = strings.TrimSpace(c.UserCommit.Summary())
|
title = strings.TrimSpace(c.UserCommit.Summary())
|
||||||
|
|
||||||
body := strings.Split(strings.TrimSpace(c.UserCommit.Message()), "\n")
|
body := strings.Split(strings.TrimSpace(c.UserCommit.Message()), "\n")
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
|
||||||
"crypto/subtle"
|
"crypto/subtle"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -327,11 +326,11 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) *git.C
|
||||||
ctx.ServerError("GetCompareInfo", err)
|
ctx.ServerError("GetCompareInfo", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
ctx.Data["NumCommits"] = compareInfo.Commits.Len()
|
ctx.Data["NumCommits"] = len(compareInfo.Commits)
|
||||||
ctx.Data["NumFiles"] = compareInfo.NumFiles
|
ctx.Data["NumFiles"] = compareInfo.NumFiles
|
||||||
|
|
||||||
if compareInfo.Commits.Len() != 0 {
|
if len(compareInfo.Commits) != 0 {
|
||||||
sha := compareInfo.Commits.Front().Value.(*git.Commit).ID.String()
|
sha := compareInfo.Commits[0].ID.String()
|
||||||
commitStatuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, sha, models.ListOptions{})
|
commitStatuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, sha, models.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("GetLatestCommitStatus", err)
|
ctx.ServerError("GetLatestCommitStatus", err)
|
||||||
|
@ -411,7 +410,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["NumCommits"] = compareInfo.Commits.Len()
|
ctx.Data["NumCommits"] = len(compareInfo.Commits)
|
||||||
ctx.Data["NumFiles"] = compareInfo.NumFiles
|
ctx.Data["NumFiles"] = compareInfo.NumFiles
|
||||||
return compareInfo
|
return compareInfo
|
||||||
}
|
}
|
||||||
|
@ -543,7 +542,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
|
||||||
ctx.Data["ConflictedFiles"] = pull.ConflictedFiles
|
ctx.Data["ConflictedFiles"] = pull.ConflictedFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["NumCommits"] = compareInfo.Commits.Len()
|
ctx.Data["NumCommits"] = len(compareInfo.Commits)
|
||||||
ctx.Data["NumFiles"] = compareInfo.NumFiles
|
ctx.Data["NumFiles"] = compareInfo.NumFiles
|
||||||
return compareInfo
|
return compareInfo
|
||||||
}
|
}
|
||||||
|
@ -559,7 +558,6 @@ func ViewPullCommits(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
pull := issue.PullRequest
|
pull := issue.PullRequest
|
||||||
|
|
||||||
var commits *list.List
|
|
||||||
var prInfo *git.CompareInfo
|
var prInfo *git.CompareInfo
|
||||||
if pull.HasMerged {
|
if pull.HasMerged {
|
||||||
prInfo = PrepareMergedViewPullInfo(ctx, issue)
|
prInfo = PrepareMergedViewPullInfo(ctx, issue)
|
||||||
|
@ -576,12 +574,10 @@ func ViewPullCommits(ctx *context.Context) {
|
||||||
|
|
||||||
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
||||||
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
||||||
commits = prInfo.Commits
|
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
commits := models.ConvertFromGitCommit(prInfo.Commits, ctx.Repo.Repository)
|
||||||
commits = models.ParseCommitsWithSignature(commits, ctx.Repo.Repository)
|
|
||||||
commits = models.ParseCommitsWithStatus(commits, ctx.Repo.Repository)
|
|
||||||
ctx.Data["Commits"] = commits
|
ctx.Data["Commits"] = commits
|
||||||
ctx.Data["CommitCount"] = commits.Len()
|
ctx.Data["CommitCount"] = len(commits)
|
||||||
|
|
||||||
getBranchData(ctx, issue)
|
getBranchData(ctx, issue)
|
||||||
ctx.HTML(http.StatusOK, tplPullCommits)
|
ctx.HTML(http.StatusOK, tplPullCommits)
|
||||||
|
|
|
@ -312,10 +312,7 @@ func renderRevisionPage(ctx *context.Context) (*git.Repository, *git.TreeEntry)
|
||||||
ctx.ServerError("CommitsByFileAndRangeNoFollow", err)
|
ctx.ServerError("CommitsByFileAndRangeNoFollow", err)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
commitsHistory = models.ValidateCommitsWithEmails(commitsHistory)
|
ctx.Data["Commits"] = models.ConvertFromGitCommit(commitsHistory, ctx.Repo.Repository)
|
||||||
commitsHistory = models.ParseCommitsWithSignature(commitsHistory, ctx.Repo.Repository)
|
|
||||||
|
|
||||||
ctx.Data["Commits"] = commitsHistory
|
|
||||||
|
|
||||||
pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5)
|
pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5)
|
||||||
pager.SetDefaultParams(ctx)
|
pager.SetDefaultParams(ctx)
|
||||||
|
|
|
@ -354,7 +354,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
theCommits := repo_module.ListToPushCommits(commits)
|
theCommits := repo_module.GitToPushCommits(commits)
|
||||||
if len(theCommits.Commits) > setting.UI.FeedMaxCommitNum {
|
if len(theCommits.Commits) > setting.UI.FeedMaxCommitNum {
|
||||||
theCommits.Commits = theCommits.Commits[:setting.UI.FeedMaxCommitNum]
|
theCommits.Commits = theCommits.Commits[:setting.UI.FeedMaxCommitNum]
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,11 +84,11 @@ func NewPullRequest(repo *models.Repository, pull *models.Issue, labelIDs []int6
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if compareInfo.Commits.Len() > 0 {
|
if len(compareInfo.Commits) > 0 {
|
||||||
data := models.PushActionContent{IsForcePush: false}
|
data := models.PushActionContent{IsForcePush: false}
|
||||||
data.CommitIDs = make([]string, 0, compareInfo.Commits.Len())
|
data.CommitIDs = make([]string, 0, len(compareInfo.Commits))
|
||||||
for e := compareInfo.Commits.Back(); e != nil; e = e.Prev() {
|
for i := len(compareInfo.Commits) - 1; i >= 0; i-- {
|
||||||
data.CommitIDs = append(data.CommitIDs, e.Value.(*git.Commit).ID.String())
|
data.CommitIDs = append(data.CommitIDs, compareInfo.Commits[i].ID.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
dataJSON, err := json.Marshal(data)
|
dataJSON, err := json.Marshal(data)
|
||||||
|
@ -611,7 +611,7 @@ func GetSquashMergeCommitMessages(pr *models.PullRequest) string {
|
||||||
|
|
||||||
limit := setting.Repository.PullRequest.DefaultMergeMessageCommitsLimit
|
limit := setting.Repository.PullRequest.DefaultMergeMessageCommitsLimit
|
||||||
|
|
||||||
list, err := gitRepo.CommitsBetweenLimit(headCommit, mergeBase, limit, 0)
|
commits, err := gitRepo.CommitsBetweenLimit(headCommit, mergeBase, limit, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Unable to get commits between: %s %s Error: %v", pr.HeadBranch, pr.MergeBase, err)
|
log.Error("Unable to get commits between: %s %s Error: %v", pr.HeadBranch, pr.MergeBase, err)
|
||||||
return ""
|
return ""
|
||||||
|
@ -620,7 +620,7 @@ func GetSquashMergeCommitMessages(pr *models.PullRequest) string {
|
||||||
posterSig := pr.Issue.Poster.NewGitSig().String()
|
posterSig := pr.Issue.Poster.NewGitSig().String()
|
||||||
|
|
||||||
authorsMap := map[string]bool{}
|
authorsMap := map[string]bool{}
|
||||||
authors := make([]string, 0, list.Len())
|
authors := make([]string, 0, len(commits))
|
||||||
stringBuilder := strings.Builder{}
|
stringBuilder := strings.Builder{}
|
||||||
|
|
||||||
if !setting.Repository.PullRequest.PopulateSquashCommentWithCommitMessages {
|
if !setting.Repository.PullRequest.PopulateSquashCommentWithCommitMessages {
|
||||||
|
@ -635,15 +635,16 @@ func GetSquashMergeCommitMessages(pr *models.PullRequest) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// commits list is in reverse chronological order
|
// commits list is in reverse chronological order
|
||||||
element := list.Back()
|
first := true
|
||||||
for element != nil {
|
for i := len(commits) - 1; i >= 0; i-- {
|
||||||
commit := element.Value.(*git.Commit)
|
commit := commits[i]
|
||||||
|
|
||||||
if setting.Repository.PullRequest.PopulateSquashCommentWithCommitMessages {
|
if setting.Repository.PullRequest.PopulateSquashCommentWithCommitMessages {
|
||||||
maxSize := setting.Repository.PullRequest.DefaultMergeMessageSize
|
maxSize := setting.Repository.PullRequest.DefaultMergeMessageSize
|
||||||
if maxSize < 0 || stringBuilder.Len() < maxSize {
|
if maxSize < 0 || stringBuilder.Len() < maxSize {
|
||||||
var toWrite []byte
|
var toWrite []byte
|
||||||
if element == list.Back() {
|
if first {
|
||||||
|
first = false
|
||||||
toWrite = []byte(strings.TrimPrefix(commit.CommitMessage, pr.Issue.Title))
|
toWrite = []byte(strings.TrimPrefix(commit.CommitMessage, pr.Issue.Title))
|
||||||
} else {
|
} else {
|
||||||
toWrite = []byte(commit.CommitMessage)
|
toWrite = []byte(commit.CommitMessage)
|
||||||
|
@ -669,7 +670,6 @@ func GetSquashMergeCommitMessages(pr *models.PullRequest) string {
|
||||||
authors = append(authors, authorString)
|
authors = append(authors, authorString)
|
||||||
authorsMap[authorString] = true
|
authorsMap[authorString] = true
|
||||||
}
|
}
|
||||||
element = element.Prev()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consider collecting the remaining authors
|
// Consider collecting the remaining authors
|
||||||
|
@ -677,25 +677,21 @@ func GetSquashMergeCommitMessages(pr *models.PullRequest) string {
|
||||||
skip := limit
|
skip := limit
|
||||||
limit = 30
|
limit = 30
|
||||||
for {
|
for {
|
||||||
list, err := gitRepo.CommitsBetweenLimit(headCommit, mergeBase, limit, skip)
|
commits, err := gitRepo.CommitsBetweenLimit(headCommit, mergeBase, limit, skip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Unable to get commits between: %s %s Error: %v", pr.HeadBranch, pr.MergeBase, err)
|
log.Error("Unable to get commits between: %s %s Error: %v", pr.HeadBranch, pr.MergeBase, err)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
}
|
}
|
||||||
if list.Len() == 0 {
|
if len(commits) == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
element := list.Front()
|
for _, commit := range commits {
|
||||||
for element != nil {
|
|
||||||
commit := element.Value.(*git.Commit)
|
|
||||||
|
|
||||||
authorString := commit.Author.String()
|
authorString := commit.Author.String()
|
||||||
if !authorsMap[authorString] && authorString != posterSig {
|
if !authorsMap[authorString] && authorString != posterSig {
|
||||||
authors = append(authors, authorString)
|
authors = append(authors, authorString)
|
||||||
authorsMap[authorString] = true
|
authorsMap[authorString] = true
|
||||||
}
|
}
|
||||||
element = element.Next()
|
|
||||||
}
|
}
|
||||||
skip += limit
|
skip += limit
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -147,7 +146,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
||||||
refName := opts.RefName()
|
refName := opts.RefName()
|
||||||
|
|
||||||
// Push new branch.
|
// Push new branch.
|
||||||
var l *list.List
|
var l []*git.Commit
|
||||||
if opts.IsNewRef() {
|
if opts.IsNewRef() {
|
||||||
if repo.IsEmpty { // Change default branch and empty status only if pushed ref is non-empty branch.
|
if repo.IsEmpty { // Change default branch and empty status only if pushed ref is non-empty branch.
|
||||||
repo.DefaultBranch = refName
|
repo.DefaultBranch = refName
|
||||||
|
@ -191,7 +190,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commits := repo_module.ListToPushCommits(l)
|
commits := repo_module.GitToPushCommits(l)
|
||||||
commits.HeadCommit = repo_module.CommitToPushCommit(newCommit)
|
commits.HeadCommit = repo_module.CommitToPushCommit(newCommit)
|
||||||
|
|
||||||
if err := repofiles.UpdateIssuesCommit(pusher, repo, commits.Commits, refName); err != nil {
|
if err := repofiles.UpdateIssuesCommit(pusher, repo, commits.Commits, refName); err != nil {
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
{{.i18n.Tr "mail.issue.action.force_push" .Doer.Name .Comment.Issue.PullRequest.HeadBranch $oldCommitLink $newCommitLink | Str2html}}
|
{{.i18n.Tr "mail.issue.action.force_push" .Doer.Name .Comment.Issue.PullRequest.HeadBranch $oldCommitLink $newCommitLink | Str2html}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{.i18n.Tr (TrN .i18n.Lang .Comment.Commits.Len "mail.issue.action.push_1" "mail.issue.action.push_n") .Doer.Name .Comment.Issue.PullRequest.HeadBranch .Comment.Commits.Len | Str2html}}
|
{{.i18n.Tr (TrN .i18n.Lang (len .Comment.Commits) "mail.issue.action.push_1" "mail.issue.action.push_n") .Doer.Name .Comment.Issue.PullRequest.HeadBranch (len .Comment.Commits) | Str2html}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</p>
|
</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -69,9 +69,8 @@
|
||||||
</div>
|
</div>
|
||||||
{{end -}}
|
{{end -}}
|
||||||
{{if eq .ActionName "push"}}
|
{{if eq .ActionName "push"}}
|
||||||
{{ $r:= List .Comment.Commits}}
|
|
||||||
<ul>
|
<ul>
|
||||||
{{range $r}}
|
{{range .Comment.Commits}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{AppUrl}}{{$.Comment.Issue.PullRequest.BaseRepo.OwnerName}}/{{$.Comment.Issue.PullRequest.BaseRepo.Name}}/commit/{{.ID}}">
|
<a href="{{AppUrl}}{{$.Comment.Issue.PullRequest.BaseRepo.OwnerName}}/{{$.Comment.Issue.PullRequest.BaseRepo.Name}}/commit/{{.ID}}">
|
||||||
{{ShortSha .ID.String}}
|
{{ShortSha .ID.String}}
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="commit-list">
|
<tbody class="commit-list">
|
||||||
{{ $r:= List .Commits}}
|
{{range .Commits}}
|
||||||
{{range $r}}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="author">
|
<td class="author">
|
||||||
{{$userName := .Author.Name}}
|
{{$userName := .Author.Name}}
|
||||||
|
@ -69,9 +68,7 @@
|
||||||
{{if IsMultilineCommitMessage .Message}}
|
{{if IsMultilineCommitMessage .Message}}
|
||||||
<button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
|
<button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if eq (CommitType .) "SignCommitWithStatuses"}}
|
|
||||||
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}}
|
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}}
|
||||||
{{end}}
|
|
||||||
{{if IsMultilineCommitMessage .Message}}
|
{{if IsMultilineCommitMessage .Message}}
|
||||||
<pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
|
<pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{{ $r:= List .comment.Commits}}
|
|
||||||
{{ $index := 0}}
|
{{ $index := 0}}
|
||||||
<div class="timeline-item commits-list">
|
<div class="timeline-item commits-list">
|
||||||
{{range $r}}
|
{{range .comment.Commits}}
|
||||||
{{ $tag := printf "%s-%d" $.comment.HashTag $index }}
|
{{ $tag := printf "%s-%d" $.comment.HashTag $index }}
|
||||||
{{ $index = Add $index 1}}
|
{{ $index = Add $index 1}}
|
||||||
<div class="singular-commit" id="{{$tag}}">
|
<div class="singular-commit" id="{{$tag}}">
|
||||||
|
@ -15,9 +14,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<span class="ui float right shabox">
|
<span class="ui float right shabox">
|
||||||
{{if eq (CommitType .) "SignCommitWithStatuses"}}
|
|
||||||
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $.root}}
|
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $.root}}
|
||||||
{{end}}
|
|
||||||
{{$class := "ui sha label"}}
|
{{$class := "ui sha label"}}
|
||||||
{{if .Signature}}
|
{{if .Signature}}
|
||||||
{{$class = (printf "%s%s" $class " isSigned")}}
|
{{$class = (printf "%s%s" $class " isSigned")}}
|
||||||
|
|
|
@ -699,7 +699,7 @@
|
||||||
{{ if .IsForcePush }}
|
{{ if .IsForcePush }}
|
||||||
{{$.i18n.Tr "repo.issues.force_push_codes" $.Issue.PullRequest.HeadBranch (ShortSha .OldCommit) ($.Issue.Repo.CommitLink .OldCommit) (ShortSha .NewCommit) ($.Issue.Repo.CommitLink .NewCommit) $createdStr | Safe}}
|
{{$.i18n.Tr "repo.issues.force_push_codes" $.Issue.PullRequest.HeadBranch (ShortSha .OldCommit) ($.Issue.Repo.CommitLink .OldCommit) (ShortSha .NewCommit) ($.Issue.Repo.CommitLink .NewCommit) $createdStr | Safe}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$.i18n.Tr (TrN $.i18n.Lang .Commits.Len "repo.issues.push_commit_1" "repo.issues.push_commits_n") .Commits.Len $createdStr | Safe}}
|
{{$.i18n.Tr (TrN $.i18n.Lang (len .Commits) "repo.issues.push_commit_1" "repo.issues.push_commits_n") (len .Commits) $createdStr | Safe}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -89,7 +89,6 @@
|
||||||
<ul>
|
<ul>
|
||||||
{{ $push := ActionContent2Commits .}}
|
{{ $push := ActionContent2Commits .}}
|
||||||
{{ $repoLink := .GetRepoLink}}
|
{{ $repoLink := .GetRepoLink}}
|
||||||
{{if $push.Commits}}
|
|
||||||
{{range $push.Commits}}
|
{{range $push.Commits}}
|
||||||
{{ $commitLink := printf "%s/commit/%s" $repoLink .Sha1}}
|
{{ $commitLink := printf "%s/commit/%s" $repoLink .Sha1}}
|
||||||
<li>
|
<li>
|
||||||
|
@ -100,7 +99,6 @@
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
|
||||||
{{if and (gt (len $push.Commits) 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" (len $push.Commits)}} »</a></li>{{end}}
|
{{if and (gt (len $push.Commits) 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" (len $push.Commits)}} »</a></li>{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in a new issue