Using pre-commit bindings to clear code

Is it a good form to clear development code from my source files during pre-commit?

For example, I have code that calls xdebug_break (), and I want to remove calls to this function from any files that it has before transferring my code to the repository. I would prefer not to check the function before calling it, because I'm the only one who needs this function.

+4
source share
2 answers

Before executing it, you must first modify the precoding code. For example, a development team might use the precommit binding to automatically reformat any code that is designed to automatically enforce command line rules.

Based on the comment, I am changing my answer - the svn manual specifically recommends AGAINST changing the contents of the commit, as it can ruin client-side caching. Git works differently since the repository is local, but I think the principle is the same.

Regarding the specific use case you mentioned; it seems a bit unconventional to use a precommit hook for this. Typically, the precommit hook is used for more general purposes. However, if you are the only developer, you can use it as you like. Just don’t forget that he is there.

0
source

Pre-commit hook should be used only to verify the commit, and not to modify it. That way, you can use it to check if you have unwanted code in your commit, and abort the commit if you don't, but you shouldn't use it to change the commit in any way.

One could use the attribute to run the program to "clean up" your sources before committing them; but I would recommend against this. Removing lines of source code can change the behavior of your program. You should not do any work that you have not tested in the form in which it is performed.

+13
source

All Articles