How to achieve “pre-validation” in Git / bitbucket?

The result of many web searches is that the pre-checkout hook in git is not yet implemented. The reason may be:

  • There is no practical application. I have a case
  • This can be achieved in any other way. Please tell me how?
  • Too hard to implement. I do not think this is the real reason.

Here is my problem:

I used pre-commit , post-merge and post-checkout hooks to support a different database for each branch.

Scenario : now when I pre-commit backup of the database, it is saved to the file using the pre-commit hook. And when I check the branch or merge, the database stored in the file is restored using post-merge and post-checkout interceptors. Now the situation is that if someone makes changes to the database after committing and checking, the changes are lost because the database was not copied. The check was successful, since there were no changes in the file structure.

So, in this case, I want to use pre-checkout to handle the database backup task in the above scenario.

+6
source share
3 answers

I understood why it was not implemented. In my situation, I make a backup copy of the database and save it in a file, which will fail every time. Therefore, to implement this functionality will be inappropriate.

0
source

You can write a script that backs up and then validates. Then create a shell alias so that it runs this script when you enter git checkout .

0
source

Using a use case for verification: delete local non-version files generated by the gulp watch:css task so that they are overwritten after verification and rebuilt by gulp.

Instead, I just write a shell script that will get the root of the repo and then delete any of the found gulp-generated files.

0
source

Source: https://habr.com/ru/post/981148/


All Articles