88 "fmt"
99 "io"
1010 "path/filepath"
11- "strings"
1211
1312 "code.gitea.io/gitea/modules/git"
1413 "code.gitea.io/gitea/modules/reqctx"
@@ -17,31 +16,18 @@ import (
1716)
1817
1918type Repository interface {
20- GetName () string
21- GetOwnerName () string
22- }
23-
24- func absPath (owner , name string ) string {
25- return filepath .Join (setting .RepoRootPath , strings .ToLower (owner ), strings .ToLower (name )+ ".git" )
19+ RelativePath () string
2620}
2721
2822func repoPath (repo Repository ) string {
29- return absPath (repo .GetOwnerName (), repo .GetName ())
30- }
31-
32- func wikiPath (repo Repository ) string {
33- return filepath .Join (setting .RepoRootPath , strings .ToLower (repo .GetOwnerName ()), strings .ToLower (repo .GetName ())+ ".wiki.git" )
23+ return filepath .Join (setting .RepoRootPath , repo .RelativePath ())
3424}
3525
3626// OpenRepository opens the repository at the given relative path with the provided context.
3727func OpenRepository (ctx context.Context , repo Repository ) (* git.Repository , error ) {
3828 return git .OpenRepository (ctx , repoPath (repo ))
3929}
4030
41- func OpenWikiRepository (ctx context.Context , repo Repository ) (* git.Repository , error ) {
42- return git .OpenRepository (ctx , wikiPath (repo ))
43- }
44-
4531// contextKey is a value for use with context.WithValue.
4632type contextKey struct {
4733 repoPath string
@@ -86,9 +72,8 @@ func DeleteRepository(ctx context.Context, repo Repository) error {
8672}
8773
8874// RenameRepository renames a repository's name on disk
89- func RenameRepository (ctx context.Context , repo Repository , newName string ) error {
90- newRepoPath := absPath (repo .GetOwnerName (), newName )
91- if err := util .Rename (repoPath (repo ), newRepoPath ); err != nil {
75+ func RenameRepository (ctx context.Context , repo , newRepo Repository ) error {
76+ if err := util .Rename (repoPath (repo ), repoPath (newRepo )); err != nil {
9277 return fmt .Errorf ("rename repository directory: %w" , err )
9378 }
9479 return nil
0 commit comments