One of our team is working on migrate their SVN repo to git. They enabled the mirror and it’s working as supposed. Then they want to add a Bitbucket Script Runner Script Pre Hook to make sure all commit has a jira issue linked, so they created a “Script Pre Hook” to check if there is a valid Jira issue ID in the commit message; if not the Pre hook will reject the commit.
This Pre hook works fine with other bitbucket repos without SVN mirror enabled; but when SVN Mirror is enabled on the repo, when a user push a commit without a Jira Issue ID in message, he got the correct Pre Hook message:
remote: One or more JIRA issues from your commits not found by query (status = “In progress”):
remote: b30c6b0e6b7: Commit not associated with a valid ticket
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to ‘ssh://email@example.com/tools/testrepo1.git’
The commit was rejected by bitbucket, but it’s still synced to the SVN repo; and later it will be synced back to bitbucket by the mirror , so this defeated the goal for the bitbucket pre hook.
It seems SVN mirror will run before the Pre Hook.
Is there any way to work around this?