An array ref specifies the contents of a directory. The referenced
array must contain a pair number of elements. Each pair consists of a
NAME_DEF and a STRUCT_DEF. The NAME_DEF specifies the name of the
component contained in the directory and the STRUCT_DEF specifies
recursively what it must be.
The NAME_DEF specifies a name in one of these ways:
If no NAME_DEF matches the component being looked for, then it is a structure violation and the commit fails.
|STRING||A string must be one of FILE and DIR, specifying what the current component must be.|
A non-zero number simply tells that whatever the current component is
is ok and finishes the check successfully.
A zero tells that whatever the current component is is a structure violation and aborts the commit.
my $tag_rx = qr/^[a-z]+-\d+\.\d+$/; # e.g. project-1.0
my $branch_rx = qr/^[a-z]+-/; # must start with letters and hifen
my $project_struct = [
META.yml => FILE,
Makefile.PL => FILE,
ChangeLog => FILE,
LICENSE => FILE,
MANIFEST => FILE,
README => FILE,
t => [
qr/\.t$/ => FILE,
lib => DIR,
trunk => $project_struct,
branches => [
$branch_rx => $project_rx,
tags => [
$tag_rx => $project_rx,
The structures first level consists of the three usual directories: trunk, tags, and branches. Anything else in this level is denied.
We require that each branch and tag have the same structure as the trunk, which is made easier by the use of the $project_struct variable. Moreover, we impose some restrictions on the names of the tags and the branches.
SVN::Hooks::CheckStructure exports a function to allow for the verification of path structures outside the context of a Subversion hook. (It would probably be better to take this function to its own module and use that module here. Well take care of that eventually.)
The function check_structure takes two arguments. The first is a STRUCT_DEF exactly the same as specified for the CHECK_STRUCTURE directive above. The second is a PATH to a file which will be checked against the STRUCT_DEF.
The funcion is intended to check paths as theyre shown by the svn ls command, i.e., with no leading slashes and with a trailing slash to indicate directories. The leading slash is assumed if its missing, but the trailing slash is needed to indicate directories.
Gustavo L. de M. Chaves <email@example.com>
This software is copyright (c) 2015 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.
|perl v5.20.3||SVN::HOOKS::CHECKSTRUCTURE (3)||2015-08-29|