Skip to content

Commit

Permalink
fix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Nov 5, 2019
1 parent 437e90d commit 6348549
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions routers/api/v1/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
Status: models.RepositoryBeingMigrated,
})
if err != nil {
handleMigrateError(ctx, remoteAddr, err)
handleMigrateError(ctx, ctxUser, remoteAddr, err)
return
}

Expand Down Expand Up @@ -466,15 +466,15 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
}()

if _, err = migrations.MigrateRepository(ctx.User, ctxUser.Name, opts); err != nil {
handleMigrateError(ctx, remoteAddr, err)
handleMigrateError(ctx, ctxUser, remoteAddr, err)
return
}

log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName)
ctx.JSON(201, repo.APIFormat(models.AccessModeAdmin))
}

func handleMigrateError(ctx *context.APIContext, remoteAddr string, err error) {
func handleMigrateError(ctx *context.APIContext, repoOwner *models.User, remoteAddr string, err error) {
switch {
case models.IsErrRepoAlreadyExist(err):
ctx.Error(409, "", "The repository with the same name already exists.")
Expand All @@ -483,7 +483,7 @@ func handleMigrateError(ctx *context.APIContext, remoteAddr string, err error) {
case migrations.IsTwoFactorAuthError(err):
ctx.Error(422, "", "Remote visit required two factors authentication.")
case models.IsErrReachLimitOfRepo(err):
ctx.Error(422, "", fmt.Sprintf("You have already reached your limit of %d repositories.", ctx.User.MaxCreationLimit()))
ctx.Error(422, "", fmt.Sprintf("You have already reached your limit of %d repositories.", repoOwner.MaxCreationLimit()))
case models.IsErrNameReserved(err):
ctx.Error(422, "", fmt.Sprintf("The username '%s' is reserved.", err.(models.ErrNameReserved).Name))
case models.IsErrNamePatternNotAllowed(err):
Expand Down

0 comments on commit 6348549

Please sign in to comment.