summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2016-05-18 17:14:55 +0100
committerSean McGivern <sean@gitlab.com>2016-05-18 17:14:55 +0100
commit27fdd3fe50bd576dc5372c9877eee0216d71c2f1 (patch)
tree075b7f3a4688a4881074e24a6472d606acf47d9a
parent636b3ebb011d7bc58c70a642c7b6920ab99c0b6d (diff)
downloadgitlab-ce-27fdd3fe50bd576dc5372c9877eee0216d71c2f1.tar.gz
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.
-rw-r--r--app/models/merge_request_diff.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index 6ad8fc3f034..7d5103748f5 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -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