Skip to content

Commit

Permalink
Merge pull request #566 from KoenDierckx/main
Browse files Browse the repository at this point in the history
Only remove safe_directory, if it exists
  • Loading branch information
pmcmaw authored Sep 12, 2022
2 parents bcae373 + c380b02 commit 99c9ee4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/puppet/provider/vcsrepo/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create
end

def destroy
remove_safe_directory if safe_directories.include?(@resource.value(:path))
remove_safe_directory
FileUtils.rm_rf(@resource.value(:path))
end

Expand Down Expand Up @@ -167,7 +167,7 @@ def update_remote_url(remote_name, remote_url)
git_with_identity('remote', 'add', remote_name, remote_url)
true

# If remote exists, but URL doesn't match, update URL
# If remote exists, but URL doesn't match, update URL
elsif !current.include? "remote.#{remote_name}.url=#{remote_url}"
git_with_identity('remote', 'set-url', remote_name, remote_url)
true
Expand Down Expand Up @@ -642,6 +642,8 @@ def add_safe_directory

# @!visibility private
def remove_safe_directory
return unless safe_directories.include?(@resource.value(:path))

notice("Removing '#{@resource.value(:path)}' from safe directory list")
args = ['config', '--global', '--unset', 'safe.directory', @resource.value(:path)]
git_with_identity(*args)
Expand Down

0 comments on commit 99c9ee4

Please sign in to comment.