SVN::H...ucture(3pm)
π NAME π
SVN::Hooks::CheckStructure β bestie, this is the plugin that does a vibe check on your repo structure. β¨
(Your terminal will show the manual header as SVN::H...ucture(3pm) because it's a User Contributed Perl Documentation page and the title got squished. She's still the same queen. π
)
πΈ VERSION πΈ
version 1.36 π
β¨ SYNOPSIS β¨
Okay so here's the tea, bestie: this SVN::Hooks plugin checks whether the files and directories being added to the repository are actually allowed by the structure definition you gave it. If they're not? π« The commit gets aborted. No cap.
It's active in the pre-commit hook. π«Ά
It's configured by this directive right here:
π CHECK_STRUCTURE(STRUCT_DEF)
This directive turns the checking on, which means the commit will absolutely get aborted if it doesn't comply. Periodt.
The STRUCT_DEF argument describes the repository structure with a recursive data structure that's one of these three:
- ARRAY REF β an array ref specifies the contents of a directory. The referenced array must contain a pair number of elements (so: even number, bestie, count them twice π). Each pair is a
NAME_DEFand aSTRUCT_DEF. TheNAME_DEFsays the name of the component sitting in that directory, and theSTRUCT_DEFsays recursively what it has to be.
The NAME_DEF specifies a name in one of these ways:
- STRING β a string specifies a name directly.
- REGEXP β a regexp specifies the class of names that match it.
- NUMBER β a number can be used as an else-clause. A non-zero number means that any name not yet matched by the previous pair must conform to the associated
STRUCT_DEF.
A zero means that no name will do and signals an error. In that case, if the STRUCT_DEF is a string, it gets used as a help message shown to the user. π₯Ί (helpful queen behavior, honestly)
If no NAME_DEF matches the component being looked for, then it's a structure violation and the commit fails. π
- STRING β a string must be one of
'FILE'and'DIR', specifying what the current component must be. - NUMBER β 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 it aborts the commit. π
Now that we have that semi-formal definition out of the way, let's try to understand it with some examples. π¦
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',
];
CHECK_STRUCTURE(
[
trunk => $project_struct,
branches => [
$branch_rx => $project_rx,
],
tags => [
$tag_rx => $project_rx,
],
],
);
So the structure's first level is the three usual directories: trunk, tags, and branches. Anything else at this level is denied. π
ββοΈ
Below the trunk we allow some usual files and two directories only: lib and t. Below trunk/t we may allow only test files with the .t extension, and below lib we allow anything. β¨
We require that each branch and tag have the same structure as the trunk, which is made easier by using the $project_struct variable. And on top of that, we impose some restrictions on the names of the tags and the branches. Slay. π
π EXPORT π
π check_structure(STRUCT_DEF, PATH)
SVN::Hooks::CheckStructure exports a function that lets you verify path structures outside the context of a Subversion hook. (The original author says it would probably be better to take this function to its own module and use that module here, and that they'll take care of that eventually. We love a self-aware king. π«Ά)
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 function returns true if the check succeeds, and dies with a proper message otherwise. πβπ
Heads up bestie: the function is intended to check paths as they're 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 it's missing, but the trailing slash is needed to indicate directories. Don't forget it or she will not know what you mean. πΈ
π AUTHOR π
Gustavo L. de M. Chaves <gnustavo@cpan.org> π
π COPYRIGHT AND LICENSE π
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. π¦
okay that's the whole page bestie, you ate π
this was SVN::H...ucture(3pm) β User Contributed Perl Documentation, running on perl v5.36.0, dated 2022-09-11. go forth and commit structurally sound things only, mwah πβ¨
π¦ where this page comes from
- ubuntu noble: libsvn-hooks-perl 1.36-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsvn-hooks-perl 1.36-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsvn-hooks-perl 1.36-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms