diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-22 13:37:55 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-22 13:37:55 +0300 |
commit | a41df736a77ee8a0ae362d7ea3d63ffd84203d1c (patch) | |
tree | f1f01947982d453baac0834ac41bc285d79bef71 /app | |
parent | 9636b08190b85b2c29b3305dd96c86b3cf789d02 (diff) | |
parent | b0ce4ca11012388b1e4fbc1d928cbf4c0da66104 (diff) |
Merge branch 'fix-pipeline-for-empty-merge-request-diff' into 'master'
Fix pipeline error when trying to read empty merge request diff
When a user pushed something which resulted an empty merge request diff, `st_commits` would be `nil`. Therefore we also need to check if there exists `st_commits`.
We could tell this from:
``` ruby
def commits
@commits ||= load_commits(st_commits || [])
end
```
and
``` ruby
def save_commits
new_attributes = {}
commits = compare.commits
if commits.present?
commits = Commit.decorate(commits, merge_request.source_project).reverse
new_attributes[:st_commits] = dump_commits(commits)
end
update_columns_serialized(new_attributes)
end
```
Closes #22438
See merge request !6470
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request_diff.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index 7362886e9f5..36b8b70870b 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -30,6 +30,10 @@ class MergeRequestDiff < ActiveRecord::Base select(column_names - ['st_diffs']) end + def st_commits + super || [] + end + # Collect information about commits and diff from repository # and save it to the database as serialized data def save_git_content @@ -83,7 +87,7 @@ class MergeRequestDiff < ActiveRecord::Base end def commits - @commits ||= load_commits(st_commits || []) + @commits ||= load_commits(st_commits) end def reload_commits |