From 39b316964caa69a2e6b9d1ad93bc4b3158d29422 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Wed, 9 Mar 2022 13:36:27 +0100 Subject: [PATCH] exec command: Only switch branch when cloning When using msync exec, I was surprised to learn it switched branches. My immediate impression was that it was simply a wrapper that executes commands on checkouts. This changes the commend to only switch branch when cloning the repository or when it's explicitly passed via the --branch option. --- lib/modulesync.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/modulesync.rb b/lib/modulesync.rb index 0e9f2c24..915a7353 100644 --- a/lib/modulesync.rb +++ b/lib/modulesync.rb @@ -199,8 +199,12 @@ def self.execute(cli_options) managed_modules.each do |puppet_module| $stdout.puts "#{puppet_module.given_name}:" - puppet_module.repository.clone unless puppet_module.repository.cloned? - puppet_module.repository.switch branch: @options[:branch] + if puppet_module.repository.cloned? + puppet_module.repository.switch branch: @options[:branch] if @options[:branch] + else + puppet_module.repository.clone + puppet_module.repository.switch branch: @options[:branch] + end command_args = cli_options[:command_args] local_script = File.expand_path command_args[0]