Skip to content

Commit

Permalink
Fix logging of Transfer API (go-gitea#19456)
Browse files Browse the repository at this point in the history
- Use the correct fullname's in tracing calls.
- Return correct function name in error.

Co-authored-by: 6543 <[email protected]>
  • Loading branch information
Gusted and 6543 authored Apr 21, 2022
1 parent c764355 commit 3ec1b6c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions routers/api/v1/repo/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,16 @@ func Transfer(ctx *context.APIContext) {
ctx.Repo.GitRepo = nil
}

oldFullname := ctx.Repo.Repository.FullName()

if err := repo_service.StartRepositoryTransfer(ctx.Doer, newOwner, ctx.Repo.Repository, teams); err != nil {
if models.IsErrRepoTransferInProgress(err) {
ctx.Error(http.StatusConflict, "CreatePendingRepositoryTransfer", err)
ctx.Error(http.StatusConflict, "StartRepositoryTransfer", err)
return
}

if repo_model.IsErrRepoAlreadyExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "CreatePendingRepositoryTransfer", err)
ctx.Error(http.StatusUnprocessableEntity, "StartRepositoryTransfer", err)
return
}

Expand All @@ -120,12 +122,12 @@ func Transfer(ctx *context.APIContext) {
}

if ctx.Repo.Repository.Status == repo_model.RepositoryPendingTransfer {
log.Trace("Repository transfer initiated: %s -> %s", ctx.Repo.Repository.FullName(), newOwner.Name)
log.Trace("Repository transfer initiated: %s -> %s", oldFullname, ctx.Repo.Repository.FullName())
ctx.JSON(http.StatusCreated, convert.ToRepo(ctx.Repo.Repository, perm.AccessModeAdmin))
return
}

log.Trace("Repository transferred: %s -> %s", ctx.Repo.Repository.FullName(), newOwner.Name)
log.Trace("Repository transferred: %s -> %s", oldFullname, ctx.Repo.Repository.FullName())
ctx.JSON(http.StatusAccepted, convert.ToRepo(ctx.Repo.Repository, perm.AccessModeAdmin))
}

Expand Down

0 comments on commit 3ec1b6c

Please sign in to comment.