Is there a way to download pre-push git-hooks from Stash to SourceTree?

Is there a way to integrate SourceTree with Stash or BitBucket, such that a pre-push git-hook could be specified server-side, and automatically installed on SourceTree clients?

This is not about pre-receive git-hooks. We're specifically looking for a way to deploy a pre-push git-hook to everyone on the team.

4 answers

1 accepted

3 votes
Accepted answer

The usual pattern for this is to commit the hook to the repository (e.g. hooks/pre-push) and then get each team member to symlink (or copy) it into their .git/hooks directory:

ln -s hooks/pre-push .git/hooks/pre-push

There is no way to enforce that a git hook runs on the client-side, you must rely on your developers to install it themselves (I usually document the process in the repositories README) and, for important hooks - e.g. running tests or lint tools - run them on the server as well.  

I'm accepting this answer, although I'm also putting in a suggestion for SourceTree. We're always looking for ways to utilize team settings to enforce standards.

I don't believe there is. Out of interest, roughly what do you want to do in the client side hook?

We're looking to enforce "all unit tests and integration tests must be run before a push". While we have these running on the server to, we'd rather our devs be pro-active then re-active when it comes to hunting down problem areas.

As Tim writes, this is an unsolved problem, normally addressed with conventions.

With the Commit Policy Plugin, we use a different approach to install dynamically generated client-side commit-msg scripts:

  1. The script, composed of multiple files, are dynamically generated on the server
  2. Those are delivered to the user as a ZIP file after he selected some options in a wizard interface
  3. After the ZIP is downloaded, he needs to extract this, and we provide a simple step-by-step for that in the same wizard

So far, it works fine. (As the scripts are dynamic, we can't include them directly in the repo content.)


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,126 views 4 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you