in my scenario i maintain a svn-synchronized git repository on a server.
all developers in my group use this repository to get their updates.
i couldn't find a way to trigger an automatic "git svn fetch" (or any other command) before a developer fetches the latest changes.
my current workaround is to have a cron job that syncs in svn related changes every 5 minutes.
is it possible to have this kind of a pre-fetch hook at all?
thanks
The pre-commit hook is run first, before you even type in a commit message. It's used to inspect the snapshot that's about to be committed, to see if you've forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.
The hook runs before a commit is accepted to git, and if the hook script fails (ie if it returns a non-zero exit code) the commit is aborted. This is powerful! It means you can automatically run linters to statically analyze your code and make sure it is high quality and syntax-error-free before the code is committed.
Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. They let you customize Git's internal behavior and trigger customizable actions at key points in the development life cycle.
pre-hook (plural pre-hooks) (computing, programming) A section of code that runs immediately before a hook call.
There is no pre-defined hook that will allow you to do exactly what you want.
If your developers are fetching over ssh, you might be able to create a wrapper script for git-upload-pack
which hides the real git-upload-pack
and calls git svn fetch
on the repository (while being absolutely sure to squash all output and errors) before execing the real git-upload-pack
.
This might be quite fiddly to set up and make robust, though. You might be better off providing a way for your developers to manually cause a call to git svn fetch
on the remote repository and encouraging them to use an alternative fetch alias that does this first (and waits for it to complete!) before doing the real fetch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With