Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-08-19 19:40:45 +0300
committerRuben Davila <rdavila84@gmail.com>2016-08-19 23:19:30 +0300
commit95cf5a09e8ca0482f01f09eb9fd321595f1eabe3 (patch)
tree5b29c3c9593c4049544d8ec71731714d6bcef86e /lib
parentaf3026c77aab072804a507ecb81c704a5a19d229 (diff)
Merge branch '20895-inline-comments-for-first-commit' into 'master'
Fix line commenting for the initial commit ## What does this MR do? Support line positions on the initial commit, where we can't compare because there's no parent commit. ## Are there points in the code the reviewer needs to double check? I chose to use the blank SHA to represent the initial commit, but it could as easily be the same SHA. I just thought this was clearer. ## Why was this MR needed? People couldn't add line comments to the initial commit! ## What are the relevant issue numbers? Closes #20895. ## Screenshots (if relevant) ![Comment_on_initial_commit](/uploads/1164448462ff55d133f3ff51c98044df/Comment_on_initial_commit.gif) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added (N/A, regression) - [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) (N/A) - [x] API support added (N/A) - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5900
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/diff/position.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/gitlab/diff/position.rb b/lib/gitlab/diff/position.rb
index 2fdcf8d7838..ecf62dead35 100644
--- a/lib/gitlab/diff/position.rb
+++ b/lib/gitlab/diff/position.rb
@@ -139,13 +139,19 @@ module Gitlab
private
def find_diff_file(repository)
- diffs = Gitlab::Git::Compare.new(
- repository.raw_repository,
- start_sha,
- head_sha
- ).diffs(paths: paths)
+ # We're at the initial commit, so just get that as we can't compare to anything.
+ if Gitlab::Git.blank_ref?(start_sha)
+ compare = Gitlab::Git::Commit.find(repository.raw_repository, head_sha)
+ else
+ compare = Gitlab::Git::Compare.new(
+ repository.raw_repository,
+ start_sha,
+ head_sha
+ )
+ end
+
+ diff = compare.diffs(paths: paths).first
- diff = diffs.first
return unless diff
Gitlab::Diff::File.new(diff, repository: repository, diff_refs: diff_refs)