From 62315ea731e6819b9326ec1dd9ca362bca9d3a7d Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Fri, 13 Aug 2021 18:26:19 +0200
Subject: [PATCH]  If PatchURL is empty, skip pull patch download when
 migrating (Partial #16356) (#16681)

Partial backport #16356

Whilst looking at adding migration support for onedev it has become apparent that gitea would attempt to pull patches on other migration targets even if that PatchURL was empty.
---
 modules/migrations/gitea_uploader.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/modules/migrations/gitea_uploader.go b/modules/migrations/gitea_uploader.go
index e852d0f885..5f34353dc4 100644
--- a/modules/migrations/gitea_uploader.go
+++ b/modules/migrations/gitea_uploader.go
@@ -555,6 +555,9 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR
 
 	// download patch file
 	err := func() error {
+		if pr.PatchURL == "" {
+			return nil
+		}
 		// pr.PatchURL maybe a local file
 		ret, err := uri.Open(pr.PatchURL)
 		if err != nil {