0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-06 04:02:12 +01:00

Set OriginalURL in API migration to match web route behavior

Fixed the API migration endpoint to set opts.OriginalURL from form.CloneAddr, ensuring consistency with the web route and preventing empty URL in system notices. Removed the TODO comment since OriginalURL is now always populated.

Since CloneAddr is a required field (binding:"Required"), OriginalURL will always be non-empty when the API validation passes.

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-30 09:02:31 +00:00
parent 1f3b3dda0d
commit e94ea1b961
2 changed files with 1 additions and 3 deletions

View File

@ -140,6 +140,7 @@ func Migrate(ctx *context.APIContext) {
}
opts := migrations.MigrateOptions{
OriginalURL: form.CloneAddr,
CloneAddr: remoteAddr,
RepoName: form.RepoName,
Description: form.Description,

View File

@ -131,9 +131,6 @@ func MigrateRepository(ctx context.Context, doer *user_model.User, ownerName str
if err1 := uploader.Rollback(); err1 != nil {
log.Error("rollback failed: %v", err1)
}
// TODO: opts.OriginalURL can be empty when migration is triggered via API (routers/api/v1/repo/migrate.go doesn't set it).
// This may result in a message like "Migrate repository (owner/repo) from failed" when OriginalURL is empty.
// Consider either: 1) ensuring OriginalURL is always set in the API, or 2) conditionally formatting this message.
if err2 := system_model.CreateRepositoryNotice(fmt.Sprintf("Migrate repository (%s/%s) from %s failed: %v", ownerName, opts.RepoName, opts.OriginalURL, err)); err2 != nil {
log.Error("create repository notice failed: ", err2)
}