#2569 delete repo local copy when transfer

Remote repository path is renamed but does not delete
outdated local copy which still has old repository path
as remote.
This commit is contained in:
Unknwon 2016-02-14 19:42:38 -05:00
parent 29cd8ac270
commit 9adfe453d5
6 changed files with 9 additions and 7 deletions

View file

@ -414,7 +414,7 @@ func (repo *Repository) ComposePayload() *api.PayloadRepo {
Email: repo.MustOwner().Email,
UserName: repo.MustOwner().Name,
},
Private: repo.IsPrivate,
Private: repo.IsPrivate,
DefaultBranch: repo.DefaultBranch,
}
}
@ -1097,11 +1097,13 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
return fmt.Errorf("transferRepoAction: %v", err)
}
// Change repository directory name.
// Rename remote repository to new path and delete local copy.
if err = os.Rename(RepoPath(owner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
return fmt.Errorf("rename repository directory: %v", err)
}
RemoveAllWithNotice("Delete repository local copy", repo.LocalCopyPath())
// Rename remote wiki repository to new path and delete local copy.
wikiPath := WikiPath(owner.Name, repo.Name)
if com.IsExist(wikiPath) {
RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath())