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

pre-commit hook will not detect new files #37

Open
vyasr opened this issue Mar 7, 2023 · 0 comments
Open

pre-commit hook will not detect new files #37

vyasr opened this issue Mar 7, 2023 · 0 comments

Comments

@vyasr
Copy link
Contributor

vyasr commented Mar 7, 2023

The pre-commit hook is designed around deleting all previously existing generated files and then generating new ones. If the end result is only a modification or deletion of existing files, this change will be noted by pre-commit and trigger hook failure, and developers may then simply stage the new changes and proceed. If, however, the hook produces new files, for instance if a new file key or matrix entry is added to dependencies.yaml, the file creation will not be treated as a failure of the hook. In order to remedy this, we need to modify rapids-dependency-file-generator to return a nonzero exit code if it produces new files. If we do not want to have dfg always behave this way (e.g. if we expect to script with it outside of pre-commit and don't want to be stopped by nonzero exit codes in some cases) we could either use a command line argument or simply provide an additional command line entry point just for the pre-commit hook.

The most elegant solution here would be to use GitPython to check the list of untracked files before and after, but we could also use the same os.walk + text parse strategy used for cleaning to get the list of generated files before and after. I assume that we would prefer that to introducing the GitPython dependency since we did so for the cleaning.

@vyasr vyasr changed the title pre-commit hook will not add new files pre-commit hook will not detect new files Mar 7, 2023
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

No branches or pull requests

1 participant