mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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:
		@@ -8,7 +8,6 @@ package git
 | 
			
		||||
import (
 | 
			
		||||
	"bufio"
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"container/list"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"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
 | 
			
		||||
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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -228,12 +227,12 @@ func (c *Commit) HasPreviousCommit(commitHash SHA1) (bool, error) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 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)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@@ -281,7 +280,7 @@ func NewSearchCommitsOptions(searchString string, forAllRefs bool) SearchCommits
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user