1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-22 16:31:12 +00:00

Refactor GitAdapter#default_branch not to unnecessarily iterate through all elements (#30828).

Patch by  Pavel Rosický.


git-svn-id: http://svn.redmine.org/redmine/trunk@17883 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2019-02-18 23:19:39 +00:00
parent b68dcfc930
commit 7b20e4c034

View File

@ -108,11 +108,11 @@ module Redmine
def default_branch def default_branch
bras = self.branches bras = self.branches
return nil if bras.nil? return unless bras
default_bras = bras.select{|x| x.is_default == true} default_bras = bras.detect{|x| x.is_default == true}
return default_bras.first.to_s if ! default_bras.empty? return default_bras.to_s if default_bras
master_bras = bras.select{|x| x.to_s == 'master'} master_bras = bras.detect{|x| x.to_s == 'master'}
master_bras.empty? ? bras.first.to_s : 'master' master_bras ? 'master' : bras.first.to_s
end end
def entry(path=nil, identifier=nil) def entry(path=nil, identifier=nil)