mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Use complete SHA to create and query commit status (#22244)
Fix #13485. Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		@@ -29,9 +29,12 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creato
 | 
			
		||||
	}
 | 
			
		||||
	defer closer.Close()
 | 
			
		||||
 | 
			
		||||
	if _, err := gitRepo.GetCommit(sha); err != nil {
 | 
			
		||||
	if commit, err := gitRepo.GetCommit(sha); err != nil {
 | 
			
		||||
		gitRepo.Close()
 | 
			
		||||
		return fmt.Errorf("GetCommit[%s]: %w", sha, err)
 | 
			
		||||
	} else if len(sha) != git.SHAFullLength {
 | 
			
		||||
		// use complete commit sha
 | 
			
		||||
		sha = commit.ID.String()
 | 
			
		||||
	}
 | 
			
		||||
	gitRepo.Close()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ func GetTreeBySHA(ctx context.Context, repo *repo_model.Repository, gitRepo *git
 | 
			
		||||
	copy(treeURL[apiURLLen:], "/git/trees/")
 | 
			
		||||
 | 
			
		||||
	// 40 is the size of the sha1 hash in hexadecimal format.
 | 
			
		||||
	copyPos := len(treeURL) - 40
 | 
			
		||||
	copyPos := len(treeURL) - git.SHAFullLength
 | 
			
		||||
 | 
			
		||||
	if perPage <= 0 || perPage > setting.API.DefaultGitTreesPerPage {
 | 
			
		||||
		perPage = setting.API.DefaultGitTreesPerPage
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user