refactor: git repo and relative path handling (#38522)

1. simplify "StorageRepo" code
2. simplify git.OpenRepository code
3. by the way, clean up some unused files in git test fixtures.
This commit is contained in:
wxiaoguang
2026-07-19 15:32:00 +08:00
committed by GitHub
parent ae176cd649
commit b06002f449
100 changed files with 315 additions and 290 deletions
+4 -4
View File
@@ -213,10 +213,10 @@ func DeleteUnadoptedRepository(ctx context.Context, doer, u *user_model.User, re
return err
}
relativePath := repo_model.RelativePath(u.Name, repoName)
exist, err := gitrepo.IsRepositoryExist(ctx, repo_model.StorageRepo(relativePath))
codeRepo := repo_model.CodeRepoByName(u.Name, repoName)
exist, err := gitrepo.IsRepositoryExist(ctx, codeRepo)
if err != nil {
log.Error("Unable to check if %s exists. Error: %v", relativePath, err)
log.Error("Unable to check if repo %s/%s exists. Error: %v", u.Name, repoName, err)
return err
}
if !exist {
@@ -235,7 +235,7 @@ func DeleteUnadoptedRepository(ctx context.Context, doer, u *user_model.User, re
}
}
return gitrepo.DeleteRepository(ctx, repo_model.StorageRepo(relativePath))
return gitrepo.DeleteRepository(ctx, codeRepo)
}
type unadoptedRepositories struct {