Skip to content

Commit d3b519a

Browse files
committed
(GH-585/CONT-998) Fix for safe_directory logic
Due to mistake in the logic unsafe directory was previously removed on every other run. The logic previously checked whether the unsafe directory needed to be added, removing it if this was false without taking into account when it was already set but we wanted it to be left in place.
1 parent 9bcaa6b commit d3b519a

File tree

1 file changed

+7
-1
lines changed
  • lib/puppet/provider/vcsrepo

1 file changed

+7
-1
lines changed

lib/puppet/provider/vcsrepo/git.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def update_safe_directory
609609

610610
if should_add_safe_directory?
611611
add_safe_directory
612-
else
612+
elsif should_remove_safe_directory?
613613
remove_safe_directory
614614
end
615615
end
@@ -637,6 +637,12 @@ def should_add_safe_directory?
637637
!safe_directories.include?(@resource.value(:path)) # directory should not already be in the list
638638
end
639639

640+
# @!visibility private
641+
def should_remove_safe_directory?
642+
(!@resource.value(:safe_directory) && # safe_directory should be false
643+
safe_directories.include?(@resource.value(:path)) # directory should be in the list
644+
end
645+
640646
# @!visibility private
641647
def git_remote_action(*args)
642648
proxy = @resource.value(:http_proxy)

0 commit comments

Comments
 (0)