mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	#1602 Wrong commit order on issue page when pushing multiple commits
This commit is contained in:
		@@ -5,7 +5,7 @@ Gogs - Go Git Service [
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
##### Current version: 0.6.14 Beta
 | 
					##### Current version: 0.6.15 Beta
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<table>
 | 
					<table>
 | 
				
			||||||
    <tr>
 | 
					    <tr>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,8 @@ SCRIPT_TYPE = bash
 | 
				
			|||||||
EXPLORE_PAGING_NUM = 20
 | 
					EXPLORE_PAGING_NUM = 20
 | 
				
			||||||
; Number of issues that are showed in one page
 | 
					; Number of issues that are showed in one page
 | 
				
			||||||
ISSUE_PAGING_NUM = 10
 | 
					ISSUE_PAGING_NUM = 10
 | 
				
			||||||
 | 
					; Number of maximum commits showed in one activity feed
 | 
				
			||||||
 | 
					FEED_MAX_COMMIT_NUM = 5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ui.admin]
 | 
					[ui.admin]
 | 
				
			||||||
; Number of users that are showed in one page
 | 
					; Number of users that are showed in one page
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							@@ -17,7 +17,7 @@ import (
 | 
				
			|||||||
	"github.com/gogits/gogs/modules/setting"
 | 
						"github.com/gogits/gogs/modules/setting"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const APP_VER = "0.6.14.0925 Beta"
 | 
					const APP_VER = "0.6.15.0925 Beta"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	runtime.GOMAXPROCS(runtime.NumCPU())
 | 
						runtime.GOMAXPROCS(runtime.NumCPU())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -189,7 +189,11 @@ func issueIndexTrimRight(c rune) bool {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// updateIssuesCommit checks if issues are manipulated by commit message.
 | 
					// updateIssuesCommit checks if issues are manipulated by commit message.
 | 
				
			||||||
func updateIssuesCommit(u *User, repo *Repository, repoUserName, repoName string, commits []*base.PushCommit) error {
 | 
					func updateIssuesCommit(u *User, repo *Repository, repoUserName, repoName string, commits []*base.PushCommit) error {
 | 
				
			||||||
	for _, c := range commits {
 | 
						// Commits are appended in the reverse order.
 | 
				
			||||||
 | 
						for i := len(commits) - 1; i >= 0; i-- {
 | 
				
			||||||
 | 
							c := commits[i]
 | 
				
			||||||
 | 
							fmt.Println(c)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		refMarked := make(map[int64]bool)
 | 
							refMarked := make(map[int64]bool)
 | 
				
			||||||
		for _, ref := range IssueReferenceKeywordsPat.FindAllString(c.Message, -1) {
 | 
							for _, ref := range IssueReferenceKeywordsPat.FindAllString(c.Message, -1) {
 | 
				
			||||||
			ref = ref[strings.IndexByte(ref, byte(' '))+1:]
 | 
								ref = ref[strings.IndexByte(ref, byte(' '))+1:]
 | 
				
			||||||
@@ -350,6 +354,10 @@ func CommitRepoAction(
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if len(commit.Commits) > setting.FeedMaxCommitNum {
 | 
				
			||||||
 | 
							commit.Commits = commit.Commits[:setting.FeedMaxCommitNum]
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bs, err := json.Marshal(commit)
 | 
						bs, err := json.Marshal(commit)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return fmt.Errorf("Marshal: %v", err)
 | 
							return fmt.Errorf("Marshal: %v", err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -777,19 +777,15 @@ func CountPublicRepositories() int64 {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RepositoriesWithUsers returns number of repos in given page.
 | 
					// RepositoriesWithUsers returns number of repos in given page.
 | 
				
			||||||
func RepositoriesWithUsers(page, pageSize int) ([]*Repository, error) {
 | 
					func RepositoriesWithUsers(page, pageSize int) (_ []*Repository, err error) {
 | 
				
			||||||
	repos := make([]*Repository, 0, pageSize)
 | 
						repos := make([]*Repository, 0, pageSize)
 | 
				
			||||||
	if err := x.Limit(pageSize, (page-1)*pageSize).Asc("id").Find(&repos); err != nil {
 | 
						if err = x.Limit(pageSize, (page-1)*pageSize).Asc("id").Find(&repos); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, repo := range repos {
 | 
						for i := range repos {
 | 
				
			||||||
		repo.Owner = &User{Id: repo.OwnerID}
 | 
							if err = repos[i].GetOwner(); err != nil {
 | 
				
			||||||
		has, err := x.Get(repo.Owner)
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		} else if !has {
 | 
					 | 
				
			||||||
			return nil, ErrUserNotExist{repo.OwnerID, ""}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,10 +23,6 @@ type UpdateTask struct {
 | 
				
			|||||||
	NewCommitId string
 | 
						NewCommitId string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					 | 
				
			||||||
	MAX_COMMITS int = 5
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func AddUpdateTask(task *UpdateTask) error {
 | 
					func AddUpdateTask(task *UpdateTask) error {
 | 
				
			||||||
	_, err := x.Insert(task)
 | 
						_, err := x.Insert(task)
 | 
				
			||||||
	return err
 | 
						return err
 | 
				
			||||||
@@ -147,10 +143,8 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
 | 
				
			|||||||
			&base.PushCommit{commit.Id.String(),
 | 
								&base.PushCommit{commit.Id.String(),
 | 
				
			||||||
				commit.Message(),
 | 
									commit.Message(),
 | 
				
			||||||
				commit.Author.Email,
 | 
									commit.Author.Email,
 | 
				
			||||||
				commit.Author.Name})
 | 
									commit.Author.Name,
 | 
				
			||||||
		if len(commits) >= MAX_COMMITS {
 | 
								})
 | 
				
			||||||
			break
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
 | 
						if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -91,12 +91,13 @@ var (
 | 
				
			|||||||
	AnsiCharset  string
 | 
						AnsiCharset  string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// UI settings.
 | 
						// UI settings.
 | 
				
			||||||
	ExplorePagingNum   int
 | 
						ExplorePagingNum     int
 | 
				
			||||||
	IssuePagingNum     int
 | 
						IssuePagingNum       int
 | 
				
			||||||
	AdminUserPagingNum int
 | 
						FeedMaxCommitNum     int
 | 
				
			||||||
	AdminRepoPagingNum int
 | 
						AdminUserPagingNum   int
 | 
				
			||||||
 | 
						AdminRepoPagingNum   int
 | 
				
			||||||
	AdminNoticePagingNum int
 | 
						AdminNoticePagingNum int
 | 
				
			||||||
	AdminOrgPagingNum int
 | 
						AdminOrgPagingNum    int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Markdown sttings.
 | 
						// Markdown sttings.
 | 
				
			||||||
	Markdown struct {
 | 
						Markdown struct {
 | 
				
			||||||
@@ -370,6 +371,7 @@ func NewContext() {
 | 
				
			|||||||
	sec = Cfg.Section("ui")
 | 
						sec = Cfg.Section("ui")
 | 
				
			||||||
	ExplorePagingNum = sec.Key("EXPLORE_PAGING_NUM").MustInt(20)
 | 
						ExplorePagingNum = sec.Key("EXPLORE_PAGING_NUM").MustInt(20)
 | 
				
			||||||
	IssuePagingNum = sec.Key("ISSUE_PAGING_NUM").MustInt(10)
 | 
						IssuePagingNum = sec.Key("ISSUE_PAGING_NUM").MustInt(10)
 | 
				
			||||||
 | 
						FeedMaxCommitNum = sec.Key("FEED_MAX_COMMIT_NUM").MustInt(5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sec = Cfg.Section("ui.admin")
 | 
						sec = Cfg.Section("ui.admin")
 | 
				
			||||||
	AdminUserPagingNum = sec.Key("USER_PAGING_NUM").MustInt(50)
 | 
						AdminUserPagingNum = sec.Key("USER_PAGING_NUM").MustInt(50)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
0.6.14.0925 Beta
 | 
					0.6.15.0925 Beta
 | 
				
			||||||
		Reference in New Issue
	
	Block a user