git resource silently fails to sync or checkout when directory already exists #7347
Labels
Focus: Resources
Focus: SCM Resources
Issues with the git and svn resources
Type: Bug
Does not work as expected.
Description
The
git
resource's:sync
action does nothing and does not fail if the target directory already exists and is not a git repo.Chef Version
14.1.2
Platform Version
I've reproduced this in Ubuntu & macOS. After looking at the implementation, this should reproduce anywhere the git resource is usable.
Replication Case
I generated a cookbook with a default recipe that looked like this
I ran
kitchen converge
thenkitchen login
to verify/test-repo
matched what was in my remote. I thenrm -rf /test-repo/.git
and added a new file to the repo on the remote. On the nextkitchen converge
the output implied nothing was wrong.Client Output
Problematic Code
From
lib/chef/provider/git.rb
In the
action_sync
method it first checks if we're dealing with an existing git repo. If we're not, we get redirected to theaction_checkout
method.In the
action_checkout
method if the target directory is not empty, we log a line about it but otherwise continue on normally.Potential Solutions
The text was updated successfully, but these errors were encountered: