App::GitHooks::Plugin::PrependTicketID - Derive a ticket ID from the branch name and prepend it to the commit-message.
If you are using the App::GitHooks::Plugin::RequireTicketID to force entering a ticket ID with each commit, it can become tedious if you need to do a lot of commits with the same ticket ID on a feature branch.
App::GitHooks::Plugin::RequireTicketID
To help with this, this plugin derives a ticket ID from the branch name and prepends it to the commit message.
Version 1.2.0
This plugin supports the following options in the main section of your .githooksrc file:
.githooksrc
project_prefixes = DEV extract_ticket_id_from_branch = /^($project_prefixes\d+)/ normalize_branch_ticket_id = s/^(.*?)(\d+)$/\U$1-$2/
Additionally, the plugin supports the following option in the [PrependTicketID] section of your .githooksrc file:
[PrependTicketID]
[PrependTicketID] commit_prefix_format = /$ticket_id: /
The list of valid ticket prefixes.
[_] project_prefixes = OPS, DEV, TEST
A regular expression with one capturing group that will extract the ticket ID from a branch name.
[_] extract_ticket_id_from_branch = /^($project_prefixes\d+)/
In the example above, if a branch is named dev1293_my_new_feature, the regular expression will identify dev1293 as the ticket ID corresponding to that branch.
dev1293_my_new_feature
dev1293
Note that:
Prefixes used for private branches are recognized properly and ignored accordingly. In other words, both dev1293_my_new_feature and ga/dev1293_my_new_feature will be identified as tied to dev1293 with the regex above.
ga/dev1293_my_new_feature
$project_prefixes is replaced at run time by the prefixes listed in the project_prefixes configuration option, to avoid duplication of information.
project_prefixes
A replacement expression to normalize the ticket ID extracted with extract_ticket_id_from_branch.
extract_ticket_id_from_branch
[_] normalize_branch_ticket_id = s/^(.*?)(\d+)$/\U$1-$2/
In the example above, dev1293_my_new_feature gave dev1293, which is then normalized as DEV-1293.
DEV-1293
A regular expression that will be used to format the prefix of the commit message.
By default, this plugin uses $ticket_id: , but the following example would turn it into ($ticket_id) :
$ticket_id:
($ticket_id)
[PrependTicketID] commit_prefix_format = /($ticket_id) /
Code to execute as part of the prepare-commit-msg hook.
my $success = App::GitHooks::Plugin::PrependTicketID->run_prepare_commit_msg();
Please report any bugs or feature requests through the web interface at https://github.com/guillaumeaubert/App-GitHooks-Plugin-PrependTicketID/issues/new. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc App::GitHooks::Plugin::PrependTicketID
You can also look for information at:
GitHub's request tracker
https://github.com/guillaumeaubert/App-GitHooks-Plugin-PrependTicketID/issues
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/app-githooks-plugin-prependticketid
CPAN Ratings
http://cpanratings.perl.org/d/app-githooks-plugin-prependticketid
MetaCPAN
https://metacpan.org/release/App-GitHooks-Plugin-PrependTicketID
Guillaume Aubert, <aubertg at cpan.org>.
<aubertg at cpan.org>
Copyright 2013-2017 Guillaume Aubert.
This code is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file for more details.
To install App::GitHooks::Plugin::PrependTicketID, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::GitHooks::Plugin::PrependTicketID
CPAN shell
perl -MCPAN -e shell install App::GitHooks::Plugin::PrependTicketID
For more information on module installation, please visit the detailed CPAN module installation guide.