Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fetch_git_dependency() to clobber files in the destination if force_fetch=True #1232

Merged

Conversation

simu
Copy link
Contributor

@simu simu commented Sep 3, 2024

Proposed Changes

When force fetching Git dependencies, we need to be able to overwrite read-only files in the destination, since Git repos may contain read-only pack and index files in .git/.

To do so, this PR introduces flag clobber_files for utils.copy_tree() which will completely clobber existing files in the
destination by setting a custom copy_function for shutil.copytree() which deletes existing destination files before copying them with shutil.copy2().

With this change, utils.copy_tree() with clobber_files=True behaves pretty much identically to distutils' copy_tree() which was used in previous versions of Kapitan.

TODO

Docs and Tests

  • Tests added
  • Updated documentation

@simu simu changed the title Fix fetch_git_dependency() to clobber files in the destination if force_fetch=True Fix fetch_git_dependency() to clobber files in the destination if force_fetch=True Sep 3, 2024
@simu simu force-pushed the fix/fetch-git-dependency-force branch 4 times, most recently from 27ee150 to e3584df Compare September 3, 2024 16:09
@ademariag ademariag marked this pull request as ready for review September 4, 2024 12:02
simu added 2 commits September 4, 2024 14:11
…force_fetch=True`

When force fetching Git dependencies, we need to be able to overwrite
read-only files in the destination, since Git repos may contain
read-only pack and index files in `.git/`.

To do so, this commit introduces flag `clobber_files` for
`utils.copy_tree()` which will completely clobber existing files in the
destination by setting a custom `copy_function` for `shutil.copytree()`
which deletes existing destination files before copying them with
`shutil.copy2()`.

With this change, `utils.copy_tree()` with `clobber_files=True` behaves
pretty much identically to distutils' `copy_tree()` which was used in
previous versions of Kapitan.
@simu simu force-pushed the fix/fetch-git-dependency-force branch from e3584df to 3f3e20c Compare September 4, 2024 12:12
@ademariag ademariag merged commit 335ab34 into kapicorp:master Sep 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants