Download patch / diff doesn't work for the initial commit
Summary
Currently GitLab supports adding .patch
or .diff
to the URL of a commit / MR to download the textual patch / diff of the commit. That works for all the commits except for the first one, which GitLab just returns a blank response. Reproducible 100% of the time on all projects.
Steps to reproduce
- Open a project, gitlab-org/ci-sample-projects/test-report for example, which only has 11 commits
- Open the first commit gitlab-org/ci-sample-projects/test-report@5e31070c, click "Options -> Download Email Patches" (alternatively add
.patch
to the URL). - GitLab sends an empty response
- But if we do the same for the second commit (gitlab-org/ci-sample-projects/test-report@75584982), it works just as expected, returning the commit in patch format
Example Project
Happens on all projects. gitlab-org/ci-sample-projects/test-report is a good example.
What is the current bug behavior?
GitLab returns empty (HTTP 200, but no content) when the user tries to download the patch / diff for the first commit in the repository.
Try curl https://gitlab.com/gitlab-org/ci-sample-projects/test-report/-/commit/5e31070c2da88ab231b80f7683a6e3ac41a57ec5.patch
What is the expected correct behavior?
GitLab returns the correctly formatted patch / diff for the initial commit.
For example, that first commit should return
Result of git format-patch -1 5e3107
From 5e31070c2da88ab231b80f7683a6e3ac41a57ec5 Mon Sep 17 00:00:00 2001
From: Maxime Orefice <morefice@gitlab.com>
Date: Fri, 13 Nov 2020 13:58:47 -0500
Subject: [PATCH] Add Readme
---
README.md | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 README.md
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4beb08e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,17 @@
+# Test report in merge request
+
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/45318) in GitLab 11.2.
+> - [Feature flag enabled by default](https://gitlab.com/gitlab-org/gitlab/-/issues/216478) in GitLab 13.3.
+> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/216478) in GitLab 13.3.
+
+This project demonstrates how to implement test reports with [GitLab CI/CD](https://docs.gitlab.com/ee/ci/README.html).
+
+You can configure your job to use Unit test reports, and GitLab will display a report on the merge request so that it’s easier and faster to identify the failure without having to check the entire log. Unit test reports currently only support test reports in the JUnit report format.
+
+Check [.gitlab-ci.yml](/.gitlab-ci.yml) to understand how to set up the feature.
+
+<img src="https://docs.gitlab.com/ee/ci/img/junit_test_report.png" alt="A merge request with test report information" align="center">
+
+---
+
+Read more about the feature on [GitLab documentation](https://docs.gitlab.com/ee/ci/unit_test_reports.html).
--
2.37.2
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
as well as on self-hosted instances
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
- Fix Gitaly RPC. Replace LeftCommitId from
0000000000000000000000000000000000000000
to4b825dc642cb6eb9a060e54bf8d69288fbee4904
for RawDiff and RawPatch. - Or send
4b825dc642cb6eb9a060e54bf8d69288fbee4904
instead of0000000000000000000000000000000000000000
from Workhorse.