git resource does not clean working directory if there are uncommitted changes #8793
Labels
Design Proposal: Accepted. PRs Welcome
Overall design approved. You build. We merge
Focus: SCM Resources
Issues with the git and svn resources
Triage: Feature Request
Indicates an issue requesting new functionality.
Description
According to the git resource docs (https://docs.chef.io/resource_git.html), the
:sync
action will hard reset and discard any untracked changes. This is true, but only if there are committed changes locally. Any uncommitted changes will cause the resource to report up-to-date, even though one would expect it to sync the source repository to overwrite those changes.Chef Version
14.4.56, but looking at the source code in master this appears to not be fixed even in the latest version.
Platform Version
Linux
Replication Case
chef-client
will not do anything to revert those changes, unless you commit them locallyRelevant Code
chef/lib/chef/provider/git.rb
Lines 94 to 106 in fc07ead
This code checks
current_revision_matches_target_revision
which is good, but since uncommitted changes don't show up in agit rev-parse HEAD
(which is how current_revision gets set) they will not trigger this check. Something else needs to be added, perhaps parsing the output ofgit status
.The text was updated successfully, but these errors were encountered: