Skip to content

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:

def commits
  @commits ||= load_commits(st_commits || [])
end

and

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 (closed)

Merge request reports

Loading