gitlab-org--gitlab-foss/app
Douwe Maan dadd28e317 Merge branch 'fix-mr-source-sha' into 'master'
Fix MergeRequest#source_sha when there is no diff

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/14170

### Overview

This MR fixes an unhandled Exception when visiting the page of an open Merge Request  without diff.

### Description

`MergeRequest#source_sha` is expected to return the sha of the source branch last commit. But when an open Merge Request has no diff (e.g. all commits have already been merged to the target branch), `merge_request.source_sha` incorrectly returns `nil`.

This was without consequences before – but since !2217 was merged (a few days ago), it makes `Gitlab::Git::Commit.between` raise an "Unexpected nil argument" exception. This can be reproduced when visiting the http://localhost:3000/gitlab-org/gitlab-test/merge_requests/2 page on a fresh local Gitlab setup.

This MR fixes the crash, by making sure that `source_sha` returns a
correct result even when there is no diff available. I also added tests.

@DouweM I believe you wrote most of this code in the first place ; does this looks correct to you, or is there a better way to resolve this issue maybe?

See merge request !3135
2016-03-18 12:28:43 +00:00
..
assets Another CS style fix 2016-03-18 11:42:15 +00:00
controllers Merge branch 'confidential-issues' into 'master' 2016-03-18 12:04:56 +00:00
finders Restrict access to confidential issues 2016-03-17 20:55:38 -03:00
helpers Restrict access to confidential issues on activity feed 2016-03-17 20:56:00 -03:00
mailers Create a SentNotification record for #relabeled_issue_email / #relabeled_merge_request_email 2016-03-15 18:36:54 +01:00
models Merge branch 'fix-mr-source-sha' into 'master' 2016-03-18 12:28:43 +00:00
services Merge branch 'confidential-issues' into 'master' 2016-03-18 12:04:56 +00:00
uploaders Revert "Merge branch 'avatar-cropping' into 'master' " 2016-03-15 14:55:40 +01:00
validators
views Merge branch 'confidential-issues' into 'master' 2016-03-18 12:04:56 +00:00
workers Back-porting PostReceive refactor made for EE 🍺 2016-03-17 00:24:12 -03:00