From 047b7ab958a7c1ea15c5fbeb265e6908a6879fc5 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 3 May 2021 17:30:39 +0200 Subject: [PATCH] Deal with nil branch default_branch doesn't guarantee a result. This checks for the nil value and raises an exception. --- lib/modulesync/repository.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/modulesync/repository.rb b/lib/modulesync/repository.rb index 1e508488..ed6d57c6 100644 --- a/lib/modulesync/repository.rb +++ b/lib/modulesync/repository.rb @@ -40,6 +40,9 @@ def default_branch def switch(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