Gustavo Leite de Mendonça Chaves > Git-Hooks > Git::Hooks::CheckRewrite

Download:
Git-Hooks-1.0.0.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  1
View/Report Bugs
Module Version: 1.0.0   Source  

NAME ^

Git::Hooks::CheckRewrite - Git::Hooks plugin for checking against unsafe rewrites

VERSION ^

version 1.0.0

DESCRIPTION ^

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:

    git config --add githooks.plugin CheckRewrite

NAME ^

Git::Hooks::CheckRewrite - Git::Hooks plugin for checking against unsafe rewrites

CONFIGURATION ^

There's no configuration needed or provided.

EXPORTS ^

This module exports the following routines that can be used directly without using all of Git::Hooks infrastructure.

record_commit_parents GIT

This is the routine used to implement the pre-commit hook. It needs a Git::More object. It simply record the original commit id and its parents in a file called GITHOOKS_CHECKREWRITE inside the git repository directory

check_commit_amend GIT

This is the routine used to implement the post-commit hook. It needs a Git::More object. It reads the original commit id and its parents from a file called GITHOOKS_CHECKREWRITE inside the git repository directory, which must have been created by the record_commit_parents routine during the pre-commit hook. Using this information it detects if this was an unsafe amend and tells the user so.

check_rebase GIT, UPSTREAM [, BRANCH]

This is the routine used to implement the pre-rebase hook. It needs a Git::More object, the name of the upstream branch onto which we're rebasing and the name of the branch being rebased. (If BRANCH is undefined it means that we're rebasing the current branch.

The routine dies with a suitable message if it detects that it will be an unsafe rebase.

REFERENCES ^

Here are some references about what it means for a rewrite to be unsafe and how to go about detecting them in git:

AUTHOR ^

Gustavo L. de M. Chaves <gnustavo@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2014 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.

syntax highlighting: