diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-04-27 15:55:05 +0000 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-04-28 17:38:38 +0800 |
commit | c6b13536dd596b7bdc58f66dffe8b803555db641 (patch) | |
tree | 70bca93a5e2dc1ea2e80a7e7771f509a0a83850f /lib | |
parent | 2d0e9173661371008685e78d88a8e6e68bfde1cd (diff) | |
download | gitlab-ce-c6b13536dd596b7bdc58f66dffe8b803555db641.tar.gz |
Merge branch '30973-fix-network-graph-ordering' into 'master'
Fix ordering of commits in the network graph.
Closes #30973
See merge request !10936
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/repository.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 41ab73abb56..dd47e7166c4 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -486,7 +486,9 @@ module Gitlab # :contains is the commit contained by the refs from which to begin (SHA1 or name) # :max_count is the maximum number of commits to fetch # :skip is the number of commits to skip - # :order is the commits order and allowed value is :date(default) or :topo + # :order is the commits order and allowed value is :none (default), :date, or :topo + # commit ordering types are documented here: + # http://www.rubydoc.info/github/libgit2/rugged/Rugged#SORT_NONE-constant) # def find_commits(options = {}) actual_options = options.dup @@ -514,11 +516,8 @@ module Gitlab end end - if actual_options[:order] == :topo - walker.sorting(Rugged::SORT_TOPO) - else - walker.sorting(Rugged::SORT_NONE) - end + sort_type = rugged_sort_type(actual_options[:order]) + walker.sorting(sort_type) commits = [] offset = actual_options[:skip] @@ -1265,6 +1264,18 @@ module Gitlab def gitaly_ref_client @gitaly_ref_client ||= Gitlab::GitalyClient::Ref.new(self) end + + # Returns the `Rugged` sorting type constant for a given + # sort type key. Valid keys are `:none`, `:topo`, and `:date` + def rugged_sort_type(key) + @rugged_sort_types ||= { + none: Rugged::SORT_NONE, + topo: Rugged::SORT_TOPO, + date: Rugged::SORT_DATE + } + + @rugged_sort_types.fetch(key, Rugged::SORT_NONE) + end end end end |