gitlab-org--gitlab-foss/app/models
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
..
ci Fix review comments 2016-03-14 13:33:26 +01:00
concerns Restrict access for confidential issues on milestone view 2016-03-17 20:55:59 -03:00
hooks Raise hook url limit 2016-01-15 00:35:12 +03:00
members Use consistent markup and styling for highlighting across blobs, diffs, blame and snippets 2016-01-21 14:23:53 +01:00
network
project_services add SHA256 to secure_compare 2016-03-08 15:57:45 +01:00
.gitkeep
ability.rb Restrict access to confidential issues 2016-03-17 20:55:38 -03:00
abuse_report.rb Clearify who deletes the user 2016-03-15 21:09:25 +01:00
appearance.rb Branded login page also in CE 2016-02-26 15:50:51 +01:00
application_setting.rb Re-add EmailValidator to avoid the repetition of format: { with: Devise.email_regexp } 2016-02-09 18:15:35 +01:00
audit_event.rb
blob.rb Refactor caching code 2016-03-07 14:27:53 +01:00
broadcast_message.rb Change ttl to 1 minute 2016-01-29 13:39:33 -05:00
commit.rb Use Gitlab::Git::DiffCollections 2016-03-03 18:38:44 +01:00
commit_range.rb Increase the minimum length for commit SHA matching to 7 2016-01-29 19:52:29 -05:00
commit_status.rb adjusted behavior so canceled builds tagged as allowed to fail do not fail build 2016-03-17 07:55:10 -07:00
deploy_key.rb
deploy_keys_project.rb
email.rb Re-add EmailValidator to avoid the repetition of format: { with: Devise.email_regexp } 2016-02-09 18:15:35 +01:00
event.rb Restrict access to confidential issues on activity feed 2016-03-17 20:56:00 -03:00
external_issue.rb Update ExternalIssue regex for JIRA integration 2016-01-26 15:55:40 -05:00
forked_project_link.rb
generic_commit_status.rb Annotate models 2016-01-06 13:09:55 +00:00
global_label.rb Updates from last code review. 2016-03-06 23:07:19 -05:00
global_milestone.rb Updates from last code review. 2016-03-06 23:07:19 -05:00
group.rb Merge branch 'share-project-ce' into 'master' 2016-03-14 16:38:52 +00:00
identity.rb Codestyle changes 2016-01-12 12:29:10 -02:00
issue.rb Restrict access to confidential issues 2016-03-17 20:55:38 -03:00
jira_issue.rb Backport JIRA service 2015-12-18 14:19:48 -06:00
key.rb Ensure "new SSH key" email do not ends up as dead Sidekiq jobs 2016-03-15 11:23:57 +01:00
label.rb Original implementation to allow users to subscribe to labels 2016-03-15 17:25:37 +01:00
label_link.rb
lfs_object.rb Update annotations 2015-12-08 21:00:01 -08:00
lfs_objects_project.rb Update annotations 2015-12-08 21:00:01 -08:00
member.rb Re-add EmailValidator to avoid the repetition of format: { with: Devise.email_regexp } 2016-02-09 18:15:35 +01:00
merge_request.rb Fix MergeRequest#source_sha when there is no diff 2016-03-16 14:02:04 +01:00
merge_request_diff.rb Show at most 100 commits in the web UI 2016-03-04 15:17:12 +01:00
milestone.rb Restrict access for confidential issues on milestone view 2016-03-17 20:55:59 -03:00
namespace.rb Make Namespace.search case-insensitive 2016-03-11 15:25:24 -05:00
note.rb Merge branch 'rs-note-active-spec' into 'master' 2016-03-14 12:53:15 -04:00
notification.rb
personal_snippet.rb Remove Snippet#expires_at 2016-03-05 18:12:17 -05:00
project.rb Cache project avatars stored in Git 2016-03-17 18:51:54 +01:00
project_group_link.rb Bring ProjectGroupLink model and migrations from EE 2016-03-11 17:47:05 +01:00
project_import_data.rb
project_snippet.rb Remove Snippet#expires_at 2016-03-05 18:12:17 -05:00
project_team.rb Allow users to access project shared with their group 2016-03-11 18:46:01 +01:00
project_wiki.rb Support Wiki with UTF-8 page name 2016-03-16 02:17:07 +09:00
protected_branch.rb
release.rb Annotate models 2015-11-13 19:22:46 +01:00
repository.rb Don't rebuild diverging commit count caches 2016-03-17 21:43:38 +01:00
security_event.rb
sent_notification.rb #can_unsubscribe? -> #?unsubscribable? 2016-01-11 14:23:45 +01:00
service.rb Greatly improve external_issue_tracker performance 2016-01-19 14:03:20 +01:00
snippet.rb Removed arel_table receiver from search methods 2016-03-11 15:25:23 -05:00
spam_log.rb Refactor Admin::SpamLogsController to block user before destroying 2016-02-02 11:25:44 -02:00
spam_report.rb Support Akismet spam checking for creation of issues via API 2016-02-02 11:25:44 -02:00
subscription.rb Improving the original label-subscribing implementation 2016-03-15 18:22:02 +01:00
todo.rb Does not raise an error when Todo is already marked as done 2016-02-23 10:43:29 -03:00
tree.rb Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-ce into lazy-blobs 2016-02-01 13:51:05 +01:00
user.rb Merge branch 'master' into 4009-external-users 2016-03-15 19:16:16 +01:00
users_star_project.rb Touch project when toggling stars to update cache 2015-12-03 16:08:08 -02:00
wiki_page.rb Support Wiki with UTF-8 page name 2016-03-16 02:17:07 +09:00