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
+6 -4
View File
@@ -157,7 +157,9 @@ func (g *RepositoryDumper) CreateRepo(ctx context.Context, repo *base.Repository
if err != nil {
return fmt.Errorf("Clone: %w", err)
}
if err := git.WriteCommitGraph(ctx, repoPath); err != nil {
repoLocal := gitcmd.RepositoryUnmanaged(repoPath)
if err := git.WriteCommitGraph(ctx, repoLocal); err != nil {
return err
}
@@ -168,7 +170,7 @@ func (g *RepositoryDumper) CreateRepo(ctx context.Context, repo *base.Repository
if err := os.MkdirAll(wikiPath, os.ModePerm); err != nil {
return fmt.Errorf("Failed to remove %s: %w", wikiPath, err)
}
wikiLocal := gitcmd.RepositoryUnmanaged(wikiPath)
if err := git.Clone(ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{
Mirror: true,
Quiet: true,
@@ -180,13 +182,13 @@ func (g *RepositoryDumper) CreateRepo(ctx context.Context, repo *base.Repository
if err := os.RemoveAll(wikiPath); err != nil {
return fmt.Errorf("Failed to remove %s: %w", wikiPath, err)
}
} else if err := git.WriteCommitGraph(ctx, wikiPath); err != nil {
} else if err := git.WriteCommitGraph(ctx, wikiLocal); err != nil {
return err
}
}
}
g.gitRepo, err = git.OpenRepository(g.gitPath())
g.gitRepo, err = git.OpenRepositoryLocal(g.gitPath())
return err
}