Issue #14904 closed
Steve Lorimer
created an issue

The ability to add a pre-receive hook to bitbucket cloud repositories would be immensely useful.

We would like to reject pushes which don't conform to repository guidelines.

Currently the only way to achieve this is opt-in using client-side hooks, which is clunky and error-prone.

Comments (5)

  1. Alastair Wilkes staff

    Hi Steve,

    Thanks for the feedback. It is highly unlikely that we will ever allow users to add arbitrary pre-receive hooks (because that would amount to letting users execute code on our servers 😄).

    That said, we have added at least one specific hook based on customer demand (required issue keys - #5658). Is there a need or set of needs we could fulfill one-by-one? If so, it'd be great to have feature requests for each one.

    Bitbucket PM

  2. Steve Lorimer reporter

    Hi Alastair

    Thanks for the response.

    The specific use case is to reject pushes which don't follow coding standards, using clang-format to verify

    The pre-commit hook works as follows:

    git diff --cached --name-only --diff-filter=ACMRT | grep "\.[cmh]$" | xargs -n1 clang-format -style=file -output-replacements-xml | grep "<replacement " >/dev/null
    if [ $? -ne 1 ]
        echo "Commit did not match clang-format"
        exit 1;

    This requires all repo members to install this as a client-side hook. Anyone who doesn't can push non-conforming code.

    It would be far more efficient to have this as a server-side pre-receive hook (overridable with a force push of course)

  3. Log in to comment