fixed 当目录中有子模块子代码且找不到commitid的情况下报错处理
(cherry picked from commit de2fd01271
)
This commit is contained in:
parent
b2624f6562
commit
b1142b9b68
|
@ -137,12 +137,12 @@ func GetReadmeContents(ctx *context.APIContext) {
|
|||
readmeSortArr := []string{"readme", "readme.en.md", "readme_en.md", "readme.md", "readme.ch.md", "readme_ch.md", "readme.zh.md", "readme_zh.md", "readme.cn.md", "readme_cn.md"}
|
||||
readmePath := ""
|
||||
readmePathInArrIndex := 0
|
||||
filesListInterface, err := files_service.GetContentsOrList(ctx, ctx.Repo.Repository, "", ref)
|
||||
filesListInterface, err := hat_files_service.GetContentsOrList(ctx, ctx.Repo.Repository, "", ref)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetContentsOrList", err)
|
||||
return
|
||||
}
|
||||
filesList, ok := filesListInterface.([]*api.ContentsResponse)
|
||||
filesList, ok := filesListInterface.([]*hat_api.ContentsResponse)
|
||||
if ok {
|
||||
for _, file := range filesList {
|
||||
for i, sortItem := range readmeSortArr {
|
||||
|
|
|
@ -134,7 +134,9 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var isTextFile = false
|
||||
|
||||
if !entry.IsSubModule() {
|
||||
blob, err := gitRepo.GetBlob(entry.ID.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -148,7 +150,8 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
|
|||
buf = buf[:n]
|
||||
|
||||
st := typesniffer.DetectContentType(buf)
|
||||
isTextFile := st.IsText()
|
||||
isTextFile = st.IsText()
|
||||
}
|
||||
|
||||
contentsResponse := &hat_api.ContentsResponse{
|
||||
ContentsResponse: &gitea_api.ContentsResponse{
|
||||
|
|
Loading…
Reference in New Issue