diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-11-15 16:06:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-15 16:06:11 +0800 |
commit | 21ae9838e04233bbf9930d368d935fd1f9b68c34 (patch) | |
tree | 610abb6f1ec2df235d469276b36f6d26e00e4653 /routers/api/v1 | |
parent | b30d744e0986dcf716d4f57dac8c72a494bb226b (diff) | |
download | gitea-21ae9838e04233bbf9930d368d935fd1f9b68c34.tar.gz gitea-21ae9838e04233bbf9930d368d935fd1f9b68c34.zip |
Move transfer repository and rename repository on a service package and start action notification (#8573)
* move transfer repository and rename repository on a service package and start action notification
* remove unused codes
* fix lint
* fix bugs
* fix test
* fix test
* fix test
* fix lint
* update go mod and sum
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/repo/repo.go | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index f7aa366b17..151475a8e9 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -631,15 +631,13 @@ func Edit(ctx *context.APIContext, opts api.EditRepoOption) { func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) error { owner := ctx.Repo.Owner repo := ctx.Repo.Repository - - oldRepoName := repo.Name newRepoName := repo.Name if opts.Name != nil { newRepoName = *opts.Name } // Check if repository name has been changed and not just a case change if repo.LowerName != strings.ToLower(newRepoName) { - if err := models.ChangeRepositoryName(ctx.Repo.Owner, repo.Name, newRepoName); err != nil { + if err := repo_service.ChangeRepositoryName(ctx.User, repo, newRepoName); err != nil { switch { case models.IsErrRepoAlreadyExist(err): ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("repo name is already taken [name: %s]", newRepoName), err) @@ -653,14 +651,6 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err return err } - err := models.NewRepoRedirect(ctx.Repo.Owner.ID, repo.ID, repo.Name, newRepoName) - if err != nil { - ctx.Error(http.StatusUnprocessableEntity, "NewRepoRedirect", err) - return err - } - - notification.NotifyRenameRepository(ctx.User, repo, oldRepoName) - log.Trace("Repository name changed: %s/%s -> %s", ctx.Repo.Owner.Name, repo.Name, newRepoName) } // Update the name in the repo object for the response |