app/models/repository.rb
# Discovers the default branch based on the repository's available branches
#
# - If no branches are present, returns nil
# - If one branch is present, returns its name
# - If two or more branches are present, returns the one that has a name
#   matching root_ref (default_branch or 'master' if default_branch is nil)
Discovers the default branch based on the repository's available branches
If no branches are present, returns nil
If one branch is present, returns its name
If two or more branches are present, returns the one that has a name
matching root_ref (default_branch or 'master' if default_branch is nil)
Discovers the default branch based on the repository ' s available branches If no branches are present returns nil If one branch is present returns its name If two or more branches are present returns the one that has a name matching root_ref ( default_branch or ' master ' if default_branch is nil )
def discover_default_branch
    if branch_names.length == 0
      nil
    elsif branch_names.length == 1
      branch_names.first
    else
      branch_names.select { |v| v == root_ref }.first
    end
  end
def discover_default_branch if branch_names . length == 0 nil elsif branch_names . length == 1 branch_names . first else branch_names . select { | v | v == root_ref } . first end end
Discovers the default branch based on the repository's available branches
 If no branches are present, returns nil
 If one branch is present, returns its name
 If two or more branches are present, returns the one that has a name
matching root_ref (default_branch or 'master' if default_branch is nil)
Discovers the default branch based on the repository ' s available branches If no branches are present returns nil If one branch is present returns its name If two or more branches are present returns the one that has a name matching root_ref ( default_branch or ' master ' if default_branch is nil )