Commit 7feb6897 authored by maeda's avatar maeda

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

Patch by  Pavel Rosický.


git-svn-id: https://svn.redmine.org/redmine/trunk@17883 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 28581c8d
......@@ -108,11 +108,11 @@ module Redmine
def default_branch
bras = self.branches
return nil if bras.nil?
default_bras = bras.select{|x| x.is_default == true}
return default_bras.first.to_s if ! default_bras.empty?
master_bras = bras.select{|x| x.to_s == 'master'}
master_bras.empty? ? bras.first.to_s : 'master'
return unless bras
default_bras = bras.detect{|x| x.is_default == true}
return default_bras.to_s if default_bras
master_bras = bras.detect{|x| x.to_s == 'master'}
master_bras ? 'master' : bras.first.to_s
end
def entry(path=nil, identifier=nil)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment