mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	[refactor] Unify the export of user data via API (#15144)
* [refactor] unify how user data is exported via API * test time via unix timestamp
This commit is contained in:
		@@ -86,13 +86,13 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ok {
 | 
			
		||||
		apiAuthor = ToUser(cacheAuthor, false, false)
 | 
			
		||||
		apiAuthor = ToUser(cacheAuthor, nil)
 | 
			
		||||
	} else {
 | 
			
		||||
		author, err := models.GetUserByEmail(commit.Author.Email)
 | 
			
		||||
		if err != nil && !models.IsErrUserNotExist(err) {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		} else if err == nil {
 | 
			
		||||
			apiAuthor = ToUser(author, false, false)
 | 
			
		||||
			apiAuthor = ToUser(author, nil)
 | 
			
		||||
			if userCache != nil {
 | 
			
		||||
				userCache[commit.Author.Email] = author
 | 
			
		||||
			}
 | 
			
		||||
@@ -108,13 +108,13 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ok {
 | 
			
		||||
		apiCommitter = ToUser(cacheCommitter, false, false)
 | 
			
		||||
		apiCommitter = ToUser(cacheCommitter, nil)
 | 
			
		||||
	} else {
 | 
			
		||||
		committer, err := models.GetUserByEmail(commit.Committer.Email)
 | 
			
		||||
		if err != nil && !models.IsErrUserNotExist(err) {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		} else if err == nil {
 | 
			
		||||
			apiCommitter = ToUser(committer, false, false)
 | 
			
		||||
			apiCommitter = ToUser(committer, nil)
 | 
			
		||||
			if userCache != nil {
 | 
			
		||||
				userCache[commit.Committer.Email] = committer
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user