puppetlabs / puppetlabs-vcsrepo

Support for source control repositories
http://forge.puppetlabs.com/puppetlabs/vcsrepo
GNU General Public License v2.0
223 stars 284 forks source link

support force-cleaning git repos #632

Open bugfood opened 8 months ago

bugfood commented 8 months ago

Summary

Add support to vcsrepo's git provider to enforce the status of the git repo. The supported statuses are "default_clean" (to clean the repo, while ignoring files in .gitignore and "ignore" (to do nothing).

Additional Context

This change is written to support other cleaning methods in the future, if desired.

The first commits fix up the existing documentation and unit tests a bit, then the last commit adds the new feature.

Checklist

bugfood commented 8 months ago

There are a couple things I couldn't do quite as well as I would like.

  1. I don't know the best way to document the possible values of a property. I don't think that newvalue accepts a desc attribute, but I could be wrong. I asked about this in the puppet community slack: https://puppetcommunity.slack.com/archives/C0W298S9G/p1703790588151839

  2. This new feature has an interaction with the revision property. If both revision and repository_status are applied, then the exact behavior depends on the order in which the properties are applied:

    • If revision happens first, then the repo is cleaned according to the .gitignore of the target revision.
    • If repository_status happens first, then the repo is cleaned according to the .gitignore of the original revision. In either case, revision does a git checkout --force by default, so some local changes may be clobbered anyway. Experimentally, revision is currently applied first, due to being listed first in the file, but I don't think there's any guarantee of this behavior. I asked about this in the puppet community slack: https://puppetcommunity.slack.com/archives/C0W298S9G/p1703791951239809

I don't think either of these issues should gate merging the PR, but I'm definitely willing to try any suggestions.

Thank you, Corey

bugfood commented 8 months ago

The remaining acceptance test failures seem to be unrelated to this PR.

-Corey

bugfood commented 8 months ago

I updated the PR to support cleaning submodules as well.

bugfood commented 8 months ago

Changes in new update:

-Corey

bugfood commented 8 months ago

Changes in new update:

-Corey