SVN::H...nfFile(3pm)

πŸ“¦
version 1.36 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

SVN::Hooks::UpdateConfFile β€” bestie, this is the plugin that keeps your repository configuration under version control. Yes, versioned. As it should be. πŸ’…


🌸 VERSION 🌸

This is version 1.36, and she's thriving.


πŸ¦‹ SYNOPSIS πŸ¦‹

Okay so listen. This SVN::Hooks plugin lets you keep the repository configuration files under version control. Revolutionary, I know. 😭

The repository configuration usually lives in the conf directory, inside the directory where the repo was created. In a brand new repository you'll see authz, passwd, and svnserve.conf sitting in there. And it's genuinely so tragic that these super important files are normally kept out of any version control system. Like, hello?? πŸ™ˆ This plugin fixes that β€” it lets you keep those files versioned under the very same repository where they're used. Iconic behaviour, honestly.

It's active in the pre-commit and the post-commit hooks.

It's configured by the following directive. πŸ‘‡

πŸŽ€ UPDATE_CONF_FILE(FROM, TO, @ARGS)

This directive makes it so that after a successful commit in which the file FROM, under version control, has been added or modified, its newest version gets copied to TO. Slay. ✨

FROM can be a string or a qr/Regexp/ specifying the file path relative to the repository's root (e.g. trunk/src/version.c or qr:^conf/(\w+).conf$:).

TO must be a relative path indicating where the original file must be copied to, below the /repo/conf directory in the server. It can be an explicit file name or a directory β€” in which case the basename of FROM is used as the name of the destination file. Non-existing directory components of TO are automatically created, no cap. ✨

Heads up bestie: if the path doesn't exist, the hook assumes it should be a file. To make sure it's understood as a directory you may end it with a forward slash (/). 🫢

If FROM is a qr/Regexp/, TO is evaluated as a string in order to allow for the interpolation of capture buffers from the regular expression. This is useful to map the copy operation to a different directory structure. For example, this configuration qr:^conf/(\w+).conf$: => '$1.conf' updates any .conf file in the repository conf directory. Main character mapping energy. πŸ‘‘

The optional @ARGS must be a sequence of pairs like these:

  • validator => ARRAY or CODE β€” A validator is a function or a command (specified by an array of strings that will be passed to the shell) that will check the contents of FROM in the pre-commit hook to see if it's valid. If there is no validator, the contents are considered valid. πŸ’–
    • The function receives three arguments:
      • A string with the contents of FROM
      • A string with the relative path to FROM in the repository
      • An SVN::Look object representing the commit transaction
    • The command is called with three arguments:
      • The path to a temporary copy of FROM
      • The relative path to FROM in the repository
      • The path to the root of the repository in the server
  • generator => ARRAY or CODE β€” A generator is a function or a command (specified by an array of strings that will be passed to the shell) that will transform the contents of FROM in the post-commit hook before copying it to TO. If there is no generator, the contents are copied as is. 🌈
    • The function receives the same three arguments as the validator's function above.
    • The command is called with the same three arguments as the validator's command above.
  • actuator => ARRAY or CODE β€” An actuator is a function or a command (specified by an array of strings that will be passed to the shell) that will be invoked after a successful commit of FROM in the post-commit hook. πŸ”₯
    • The function receives the same three arguments as the validator's function above.
    • The command is called with the same three arguments as the validator's command above.
  • rotate => NUMBER β€” By default, after each successful commit the TO file is overwritten by the new contents of FROM. With this option, the last NUMBER versions of TO are kept on disk with numeric suffixes ranging from .0 to .NUMBER-1. This can be useful, for instance, in case you manage to commit a wrong authz file that denies any subsequent commit. 😭 (we've all been there, no judgement)
  • remove => BOOL β€” By default, if FROM is deleted in the commit, nothing happens to TO. If you want to have the file TO removed from the repository when FROM is deleted, set this option to a true value such as '1'. πŸ’€

And here are the examples, bestie, copied exactly because they're precious:

UPDATE_CONF_FILE(
    'conf/authz' => 'authz',
    validator    => ['/usr/local/bin/svnauthcheck'],
    generator    => ['/usr/local/bin/authz-expand-includes'],
    actuator     => ['/usr/local/bin/notify-auth-change'],
    rotate       => 2,
);

UPDATE_CONF_FILE(
    'conf/svn-hooks.conf' => 'svn-hooks.conf',
    validator    => [qw(/usr/bin/perl -c)],
    actuator     => sub {
                        my ($contents, $file) = @_;
                        die "Can't use Gustavo here." if $contents =~ /gustavo/;
                    },
    rotate       => 2,
);

UPDATE_CONF_FILE(
    qr:/file(\n+)$:' => 'subdir/$1/file',
    rotate       => 2,
    remove       => 1,
);

πŸ‘‘ AUTHOR πŸ‘‘

Gustavo L. de M. Chaves <gnustavo@cpan.org> β€” the icon, the legend. 🫢


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.


And that's the whole vibe, bestie β€” this page was brought to you by perl v5.36.0, dated 2022-09-11, for SVN::Hooks::UpdateConfFile(3pm). πŸ’– Go keep your conf directory versioned like the main character you are. Periodt. βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from