From e73f234156f8f74322a079f9320d4aeb50e441ce Mon Sep 17 00:00:00 2001 From: Erik Seliger Date: Sun, 1 Mar 2020 05:19:24 +0100 Subject: [PATCH 1/2] Fix new git based diff generation file paths --- cmd/src/actions_exec_backend_runner.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/src/actions_exec_backend_runner.go b/cmd/src/actions_exec_backend_runner.go index e8329e0230..e6371147b9 100644 --- a/cmd/src/actions_exec_backend_runner.go +++ b/cmd/src/actions_exec_backend_runner.go @@ -239,7 +239,8 @@ func runAction(ctx context.Context, prefix, repoID, repoName, rev string, steps return nil, errors.Wrap(err, "git add failed") } - diffOut, err := runGitCmd("diff", "--cached") + // --no-prefix omits the a/ and b/ folder prefixes, otherwise the diff would be interpreted as renaming the file + diffOut, err := runGitCmd("diff", "--cached", "--no-prefix") if err != nil { return nil, errors.Wrap(err, "git diff failed") } From 356be2218d045fb9e6d64509b939e85199688bc1 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Mon, 2 Mar 2020 11:48:06 +0100 Subject: [PATCH 2/2] Update cmd/src/actions_exec_backend_runner.go --- cmd/src/actions_exec_backend_runner.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/src/actions_exec_backend_runner.go b/cmd/src/actions_exec_backend_runner.go index e6371147b9..f271919fe0 100644 --- a/cmd/src/actions_exec_backend_runner.go +++ b/cmd/src/actions_exec_backend_runner.go @@ -239,7 +239,10 @@ func runAction(ctx context.Context, prefix, repoID, repoName, rev string, steps return nil, errors.Wrap(err, "git add failed") } - // --no-prefix omits the a/ and b/ folder prefixes, otherwise the diff would be interpreted as renaming the file + // As of Sourcegraph 3.14 we only support unified diff format. + // That means we need to strip away the `a/` and `/b` prefixes with `--no-prefix`. + // See: https://github.com/sourcegraph/sourcegraph/blob/82d5e7e1562fef6be5c0b17f18631040fd330835/enterprise/internal/campaigns/service.go#L324-L329 + // diffOut, err := runGitCmd("diff", "--cached", "--no-prefix") if err != nil { return nil, errors.Wrap(err, "git diff failed")