Skip to content
Snippets Groups Projects
Commit 27fdd3fe authored by Sean McGivern's avatar Sean McGivern
Browse files

Maintain commit order in MRs

`Gitlab::Git::Compare` will already have the correct order; sorting in
Ruby can only ruin that. (The correct order being the same as `git log`
- reverse chronological while maintaining the commit graph.)

As an example, imagine a branch where someone has their system clock set
wrong for some of the commits. Not only will those commits be in the
wrong order - which is maybe reasonable - but sorting in Ruby can also
put commits with the same timestamp out of order, as Ruby's sorting
isn't stable.
parent 636b3ebb
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -98,9 +98,7 @@ class MergeRequestDiff < ActiveRecord::Base
commits = compare.commits
 
if commits.present?
commits = Commit.decorate(commits, merge_request.source_project).
sort_by(&:created_at).
reverse
commits = Commit.decorate(commits, merge_request.source_project).reverse
end
 
commits
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment