Git::Hooks::CheckRewrite - Git::Hooks plugin for checking against unsafe rewrites
version 3.3.1
As a Git::Hooks plugin you don't use this Perl module directly. Instead, you may configure it in a Git configuration file like this:
Git::Hooks
[githooks] # Enable the plugin plugin = CheckRewrite # These users are exempt from all checks admin = joe molly
This section enables the plugin and defines the users joe and molly as administrators, effectively exempting them from any restrictions the plugin may impose.
joe
molly
This Git::Hooks plugin hooks itself to the pre-rebase hook to guarantee that it is safe in the sense that no rewritten commit is reachable by other branch than the one being rebased.
It also hooks itself to the pre-commit and the post-commit hooks to detect unsafe git commit --amend commands after the fact. An amend is unsafe if the original commit is still reachable by any branch after being amended. Unfortunately git still does not provide a way to detect unsafe amends before committing them.
To enable it you should add it to the githooks.plugin configuration option:
[githooks] plugin = CheckRewrite
There's no configuration needed or provided.
Here are some references about what it means for a rewrite to be unsafe and how to go about detecting them in git:
http://git.661346.n2.nabble.com/pre-rebase-safety-hook-td1614613.html
http://git.apache.org/xmlbeans.git/hooks/pre-rebase.sample
http://www.mentby.com/Group/git/rfc-pre-rebase-refuse-to-rewrite-commits-that-are-reachable-from-upstream.html
http://git.661346.n2.nabble.com/RFD-Rewriting-safety-warn-before-when-rewriting-published-history-td7254708.html
Gustavo L. de M. Chaves <gnustavo@cpan.org>
This software is copyright (c) 2022 by CPQD <www.cpqd.com.br>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Git::Hooks, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Git::Hooks
CPAN shell
perl -MCPAN -e shell install Git::Hooks
For more information on module installation, please visit the detailed CPAN module installation guide.