mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 09:04:45 +01:00
parent
9e842c8a72
commit
b627f1131b
1 changed files with 10 additions and 1 deletions
|
@ -1580,10 +1580,19 @@ func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error)
|
|||
}
|
||||
|
||||
// Change repository directory name.
|
||||
if err = os.Rename(repo.RepoPath(), RepoPath(u.Name, newRepoName)); err != nil {
|
||||
newRepoPath := RepoPath(u.Name, newRepoName)
|
||||
if err = os.Rename(repo.RepoPath(), newRepoPath); err != nil {
|
||||
return fmt.Errorf("rename repository directory: %v", err)
|
||||
}
|
||||
|
||||
localPath := repo.LocalCopyPath()
|
||||
if com.IsExist(localPath) {
|
||||
_, err := git.NewCommand("remote", "set-url", "origin", newRepoPath).RunInDir(localPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("git remote set-url origin %s: %v", newRepoPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
wikiPath := repo.WikiPath()
|
||||
if com.IsExist(wikiPath) {
|
||||
if err = os.Rename(wikiPath, WikiPath(u.Name, newRepoName)); err != nil {
|
||||
|
|
Loading…
Reference in a new issue