• Rémy Coutable's avatar
    Merge branch 'fix-pipeline-for-empty-merge-request-diff' into 'master' · 465e0e48
    Rémy Coutable authored
    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
    465e0e48
merge_request_diff_spec.rb 2.81 KB