I'd like to add a Git pre-commit hook to the Databricks Cluster.
This pre-commit hook should be executed when pushing to GitHub.
Why would I need a pre-commit hook on a Databricks Cluster?
My goal is to run blackbricks and format all notebooks automatically, so that well formatted code is pushed to GutHub only.
Is it possible to add a pre-commit hook to a Databricks Cluster?
I've found /root/.gitconfig on my cluster with this content:
[credential]
helper = cache
git config --global --list says:
credential.helper=cache
So, this seems to be the right (starting) place.
I've tried this:
git config -f /root/.gitconfig core.hooksPath /root/git-hooks
git config --global --list says now:
credential.helper=cache
core.hookspath=/root/git-hooks
Then I've added a pre-commit hook to the directory /root/git-hooks
The content of the pre-commit hook is:
touch /root/git-hooks/test.sample
This works, if I run it manually. The file test.sample is created in /root/git-hooks/.
File test.sample deleted.
In Databricks UI:
- checkout branch
- do some change
- push
The file test.sample in /root/git-hooks/ has not been created -> The pre-commit hook was not executed.
What can I do to add a pre-commit hook to a Databricks Cluster, so that this pre-commit hook is executed before the commit (to the remote branch) is added?