Compare commits

...

2 Commits

Author SHA1 Message Date
xxq250 b1142b9b68 fixed 当目录中有子模块子代码且找不到commitid的情况下报错处理
(cherry picked from commit de2fd01271)
2024-06-18 14:35:26 +08:00
xxq250 b2624f6562 fixed 代码行统计方式调整 2024-06-11 10:58:21 +08:00
3 changed files with 20 additions and 16 deletions

View File

@ -59,7 +59,8 @@ func GetCodeActivityStatsWithoutSince(repo *gitea_git.Repository, branch string)
if len(branch) == 0 {
gitCmd.AddArguments("--branches=*")
} else {
gitCmd.AddArguments("--first-parent").AddDynamicArguments(branch)
//gitCmd.AddArguments("--first-parent").AddDynamicArguments(branch)
gitCmd.AddArguments("--branches").AddDynamicArguments(branch)
}
stderr := new(strings.Builder)

View File

@ -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 {

View File

@ -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{