| 1 | package SVN::Hooks::CheckCapability; | ||
| 2 | # ABSTRACT: Check the svn client capabilities. | ||
| 3 | $SVN::Hooks::CheckCapability::VERSION = '1.35'; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | use Carp; | ||
| 8 | use SVN::Hooks; | ||
| 9 | |||
| 10 | use Exporter qw/import/; | ||
| 11 | my $HOOK = 'CHECK_CAPABILITY'; | ||
| 12 | our @EXPORT = ($HOOK); | ||
| 13 | |||
| 14 | |||
| 15 | my @Capabilities; | ||
| 16 | |||
| 17 | sub CHECK_CAPABILITY { | ||
| 18 | push @Capabilities, @_; | ||
| 19 | |||
| 20 | START_COMMIT(\&start_commit); | ||
| 21 | |||
| 22 | return 1; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub start_commit { | ||
| 26 | my ($repo_path, $user, $capabilities, $txt_name) = @_; | ||
| 27 | |||
| 28 | $capabilities ||= ''; # pre 1.5 svn clients don't pass the capabilities | ||
| 29 | |||
| 30 | # Create a hash to facilitate the checks | ||
| 31 | my %supported; | ||
| 32 | @supported{split /:/, $capabilities} = undef; | ||
| 33 | |||
| 34 | # Grok which required capabilities are missing | ||
| 35 | my @missing = grep {! exists $supported{$_}} @Capabilities; | ||
| 36 | |||
| 37 | if (@missing) { | ||
| 38 | croak "$HOOK: Your subversion client does not support the following capabilities:\n\n\t", | ||
| 39 | join(', ', @missing), | ||
| 40 | "\n\nPlease, consider upgrading to a newer version of your client.\n"; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | 1; # End of SVN::Hooks::CheckCapability | ||
| 45 | |||
| 46 | __END__ |