mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	* response 404 for diff/patch of a commit that not exist fix #15217 Signed-off-by: a1012112796 <1012112796@qq.com> * Update routers/repo/commit.go Co-authored-by: silverwind <me@silverwind.io> * use ctx.NotFound() Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
		@@ -47,7 +47,7 @@ func GetRawDiffForFile(repoPath, startCommit, endCommit string, diffType RawDiff
 | 
				
			|||||||
func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diffType RawDiffType, file string, writer io.Writer) error {
 | 
					func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diffType RawDiffType, file string, writer io.Writer) error {
 | 
				
			||||||
	commit, err := repo.GetCommit(endCommit)
 | 
						commit, err := repo.GetCommit(endCommit)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return fmt.Errorf("GetCommit: %v", err)
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	fileArgs := make([]string, 0)
 | 
						fileArgs := make([]string, 0)
 | 
				
			||||||
	if len(file) > 0 {
 | 
						if len(file) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@
 | 
				
			|||||||
package repo
 | 
					package repo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
	"path"
 | 
						"path"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -341,6 +342,11 @@ func RawDiff(ctx *context.Context) {
 | 
				
			|||||||
		git.RawDiffType(ctx.Params(":ext")),
 | 
							git.RawDiffType(ctx.Params(":ext")),
 | 
				
			||||||
		ctx.Resp,
 | 
							ctx.Resp,
 | 
				
			||||||
	); err != nil {
 | 
						); err != nil {
 | 
				
			||||||
 | 
							if git.IsErrNotExist(err) {
 | 
				
			||||||
 | 
								ctx.NotFound("GetRawDiff",
 | 
				
			||||||
 | 
									errors.New("commit "+ctx.Params(":sha")+" does not exist."))
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		ctx.ServerError("GetRawDiff", err)
 | 
							ctx.ServerError("GetRawDiff", err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user