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:
parent
1f3b3dda0d
commit
e94ea1b961
@ -140,6 +140,7 @@ func Migrate(ctx *context.APIContext) {
|
||||
}
|
||||
|
||||
opts := migrations.MigrateOptions{
|
||||
OriginalURL: form.CloneAddr,
|
||||
CloneAddr: remoteAddr,
|
||||
RepoName: form.RepoName,
|
||||
Description: form.Description,
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user