summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-12-15 00:59:16 +0000
committerGitHub <noreply@github.com>2022-12-15 08:59:16 +0800
commitdd2343d01fff8851009545aac93e712549183655 (patch)
tree726c950671c93c3bb1a813a77ad04f61fc4f3825 /services
parent9e49270676f4c38e5bff3679ddbca6a92f6325e0 (diff)
downloadgitea-dd2343d01fff8851009545aac93e712549183655.tar.gz
gitea-dd2343d01fff8851009545aac93e712549183655.zip
Correctly handle moved files in apply patch (#22118) (#22135)
Backport #22118 Moved files in a patch will result in git apply returning: ``` error: {filename}: No such file or directory ``` This wasn't handled by the git apply patch code. This PR adds handling for this. Fix #22083 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'services')
-rw-r--r--services/pull/patch.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/services/pull/patch.go b/services/pull/patch.go
index 9b87ac22e2..d3e049fc1b 100644
--- a/services/pull/patch.go
+++ b/services/pull/patch.go
@@ -53,6 +53,8 @@ var patchErrorSuffices = []string{
": patch does not apply",
": already exists in working directory",
"unrecognized input",
+ ": No such file or directory",
+ ": does not exist in index",
}
// TestPatch will test whether a simple patch will apply
@@ -416,6 +418,7 @@ func checkConflicts(ctx context.Context, pr *issues_model.PullRequest, gitRepo *
scanner := bufio.NewScanner(stderrReader)
for scanner.Scan() {
line := scanner.Text()
+ log.Trace("PullRequest[%d].testPatch: stderr: %s", pr.ID, line)
if strings.HasPrefix(line, prefix) {
conflict = true
filepath := strings.TrimSpace(strings.Split(line[len(prefix):], ":")[0])