Skip to content

Commit

Permalink
Deal with nil branch
Browse files Browse the repository at this point in the history
default_branch doesn't guarantee a result. This checks for the nil value
and raises an exception.
  • Loading branch information
ekohl committed May 3, 2021
1 parent 44b3e75 commit 7da6a12
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/modulesync/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def default_branch
def switch_branch(branch)
unless branch
branch = default_branch
unless branch
raise "Unable to detect default branch"
end
puts "Using repository's default branch: #{branch}"
end
return if repo.current_branch == branch
Expand Down

0 comments on commit 7da6a12

Please sign in to comment.