Looking to submit a support request? We are now a Perforce company, please submit any requests on our new support page.
Follow

Local Git hook setup

 

The Git hooks are needed in order to associates a Git commit to a Hansoft item. The client-side hook is responsible for fetching links to the Hansoft items and adding these as tags in the commit message. It can be installed as either prepare-commit-msg (the default) or commit-msg.

Note: Git users are matched against Hansoft users using their e-mail address. Verify that they are correctly set up in both Git and Hansoft.

Installing through install script

The local hook can be installed with the supplied install_local_hook.sh script. This will copy all files into ~/.hansoft_git_integration and add the hook to your local git template.

Run the script (On Windows: inside for example GitBash or Cygwin) and follow the instructions provided.

You can then enable the hook inside your repositories by running git init, note that if you already have a prepare-commit-msg hook you will have to manually add a call to ~/.hansoft_git_integration/prepare-commit-msg "$@"

Editing hansoft.conf

Edit hansoft.conf to match your environment, beginning with the hostname for the server running the integration service.

HansoftGitIntegrationHost=integrationHost

 

By default the repository identifier is extracted from the GIT_DIR environment variable. If you have a non-standard setup the identifier needs to be specified to reflect your integration service configuration.

HansoftRepositoryIdentifier="repo"

 

There are also two optional flags that can be set in hansoft.conf.

HansoftGitIntegrationErrorIsFatal dictates how an error is to be treated by Git in case of an error message from the integration service.

HansoftTagsPrepend allows you to specify a string that is to be prepended to the list of Hansoft issues in the Git commit message.

Manually copying files

Copy hansoft.conf, the HPMGitHook executable for your platform and prepare-commit-msg to each local repository.

You can also keep the files in a shared directory and symlink only the hook scripts into .git/hooks

This way the config file will be shared and any differences per repository will have to be specified through logic in the config file.

Testing

Executing prepare-commit-msg without any parameters will perform a connection test to the integration server. If run within a Git repository it will also pop up a notifier on all matched Hansoft clients which has that repository mapped.

Third party Git tools

Some Git tools may require additional steps to make use of the Hansoft Git integration, the propagation of hook calls being the most common one. The tools documentation should describe the necessary setup for additional hooks.

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request