Skip to content

Commit

Permalink
Set master as default branch if it is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-sig committed Oct 15, 2024
1 parent f534bec commit 98214c5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/ohloh_scm/git/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ def branch?(name = scm.branch_name)
end

def default_branch
return unless exist?
return standard_default_branch unless exist?

run("git remote show '#{scm.url}' | grep 'HEAD branch' | awk '{print $3}'").strip
name = run("git remote show '#{scm.url}' | grep 'HEAD branch' | awk '{print $3}'").strip
name.present? ? name : standard_default_branch
end

private

def standard_default_branch
'master'
end
end
end
Expand Down

0 comments on commit 98214c5

Please sign in to comment.