Hello
we are using Bitbucket for a couple of projects, and we have added a pre-receive hook that checks the commits message for the presence of a valid JIRA issue : the script parses each commit message, extract JIRA issue references (must find at least one), and check the issues are in "In Progress" status. If one commit does not satisfy the rules, the push is rejected.
This works fine for development: the developer creates a JIRA issues, commit changes with respect to it, pushes, then closes the JIRA issue once done.
But when a user wants to reintegrate the changes made to another branch, then the script hook will check again the commit messages and reject it because the JIRA issue is closed.
*Example*:
- Developer A makes 5 commits on branch A with a valid JIRA-Ticket A
- Developer A pushes the 5 commits to the repository
- Developer A closes the ticket because the feature is done
- Developer B works on branch B and merges branch A into his branch to get the latest feature
- The 5 commits done by Developer A are now part of branch B with their commit-message referencing JIRA-Ticket A
- Developer B tries to push his merged branch B into the repository
- Developer B gets an error message because there are commits in his push that reference the already-closed JIRA-Ticket A
A similar problem is produced when Pull Requests are merged using the BitBucket Web-UI. The commits that perform the merge do have auto-generated commit messages without a JIRA Ticket. When a developer merges these commits into his working branch, the next pull will fail because the commits he now has in his branch do not have a jira ticket.
Is there a way to work around this? Is there a way to exclude merge and pull request commits from the pre-receive hook ?
Regards