Merge pull request 'compare接口遵循旧版,创建文件分支名%处理' (#38) from yystopf/gitea-1156:develop into develop

This commit is contained in:
yystopf 2021-12-23 10:10:04 +08:00
commit c617532f47
2 changed files with 8 additions and 2 deletions

View File

@ -188,6 +188,7 @@ func GetContents(repo *models.Repository, treePath, ref string, forList bool) (*
}
// Handle links
if entry.IsRegular() || entry.IsLink() {
ref = fmt.Sprintf("%s", strings.Replace(ref, "%", "%25", -1))
downloadURL, err := url.Parse(fmt.Sprintf("%s/raw/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath))
if err != nil {
return nil, err

View File

@ -1152,8 +1152,13 @@ func PrepareCompareDiff(
ctx.ServerError("GetDiffRange", err)
return false
}
if diff.NumFiles == 0 {
ctx.Data["Diff"] = nil
ctx.Data["DiffNotAvailable"] = true
} else {
ctx.Data["Diff"] = diff
ctx.Data["DiffNotAvailable"] = diff.NumFiles == 0
ctx.Data["DiffNotAvailable"] = false
}
return false
}