NAME

Git::MoreHooks::GitRepoAdmin - Integrate with .git-repo-admin

VERSION

version 0.017

SYNOPSIS

Git::MoreHooks::GitRepoAdmin is a plugin for Git::Hooks.

DESCRIPTION

This plugin works with .git-admin-repo.

It has several functions:

  • Server Side

    On server side during git push it updates the Git hooks automatically when there is configuration changes, i.e. when the VERSION file is updated with a greater number than earlier.

  • Client Side

    On client side during git pull it only informs the user when there is configuration changes. It does not perform any changes to user's repo.

STATUS

Package Git::MoreHooks is currently being developed so changes in the existing hooks are possible.

USAGE

To enable GitRepoAdmin plugin, you need to add it to the githooks.plugin configuration option:

git config --add githooks.plugin Git::MoreHooks::GitRepoAdmin

GitRepoAdmin plugin attaches itself to the following Git hooks:

  • post-merge

    This hook is invoked by git-merge, which happens when a git pull is done on a local repository.

  • post-receive

    This hook is invoked by git-receive-pack when it reacts to git push and updates reference(s) in its repository. It executes on the remote repository once after all the refs have been updated.

CONFIGURATION

This plugin is configured by the following git options.

githooks.gitrepoadmin.ref REFSPEC

By default this plugin only reacts to updates on branches main or master. If you want to react to some other refs (usually some branch under refs/heads/), you may specify them with one or more instances of this option. N.B. Other good candidates are, for instance, branches develop and release.

The refs can be specified as a complete ref name (e.g. "refs/heads/master") or by a regular expression starting with a caret (^), which is kept as part of the regexp (e.g. "^refs/heads/(master|fix)").

Default value for REFSPEC is [ '^refs/heads/main$', '^refs/heads/master$' ].

N.B. REFSPEC must not match two or more branch names in the repo.

N.B.2. Due to the latest change of default branch name from master to main, both names are now supported by default. However, as above, the repository must not have both of them. If you want to have both of them, then you must define REFSPEC to match only one.

EXPORTS

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

check_affected_refs_client_side GIT, INT

This is the routine used to implement the post-merge hook. It needs a Git::More object and an integer telling if this was a squash merge (1) or not (0).

check_affected_refs_server_side GIT

This is the routing used to implement the post-receive hook. It needs a Git::More object.

NOTES

Thanks go to Gustavo Leite de Mendonça Chaves for his Git::Hooks package.

BUGS AND LIMITATIONS

No known bugs.

AUTHOR

'Mikko Koivunalho <mikkoi@cpan.org>'

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Mikko Koivunalho.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.