瀏覽代碼

Change local copy origin url after repository rename (#3399)

Fix #3378
tags/v1.4.0-rc1
Wendell Sun 6 年之前
父節點
當前提交
b627f1131b
共有 1 個檔案被更改,包括 10 行新增1 行删除
  1. 10
    1
      models/repo.go

+ 10
- 1
models/repo.go 查看文件

@@ -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…
取消
儲存