From c73cb4415da492d574d6bdc2ff2d1b602981e91e Mon Sep 17 00:00:00 2001 From: maddes-b Date: Mon, 7 Sep 2020 20:06:56 +0200 Subject: [PATCH] Check also property-modified files in hook script check-mime-type.pl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * contrib/hook-scripts/check-mime-type.pl: (proplist) add property-modified files for checks Patch by: Matthias Bücher Suggested by: Leo Davis [1] [1] https://mail-archives.apache.org/mod_mbox/subversion-dev/201403.mbox/%3C1576503.m6XB7udPXQ@hurry.speechfxinc.com%3E --- contrib/hook-scripts/check-mime-type.pl | 41 ++++++++++++++----------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/contrib/hook-scripts/check-mime-type.pl b/contrib/hook-scripts/check-mime-type.pl index 3ded119f27..79c37d26eb 100755 --- a/contrib/hook-scripts/check-mime-type.pl +++ b/contrib/hook-scripts/check-mime-type.pl @@ -1,18 +1,19 @@ #!/usr/bin/env perl # ==================================================================== -# commit-mime-type-check.pl: check that every added file has the -# svn:mime-type property set and every added file with a mime-type -# matching text/* also has svn:eol-style set. If any file fails this -# test the user is sent a verbose error message suggesting solutions and -# the commit is aborted. +# check-mime-type.pl: check that every added or property-modified file +# has the svn:mime-type property set and every added or property-modified +# file with a mime-type matching text/* also has svn:eol-style set. +# If any file fails this test the user is sent a verbose error message +# suggesting solutions and the commit is aborted. # -# Usage: commit-mime-type-check.pl REPOS TXN-NAME +# Usage: check-mime-type.pl REPOS TXN-NAME # ==================================================================== -# Most of commit-mime-type-check.pl was taken from +# Most of check-mime-type.pl was taken from # commit-access-control.pl, Revision 9986, 2004-06-14 16:29:22 -0400. # ==================================================================== # Copyright (c) 2000-2004 CollabNet. All rights reserved. +# Copyright (c) 2014-2020 Apache Software Foundation (ASF). # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -25,6 +26,9 @@ # history and logs, available at http://subversion.tigris.org/. # ==================================================================== +use strict; +use Carp; + # Turn on warnings the best way depending on the Perl version. BEGIN { if ( $] >= 5.006_000) @@ -33,9 +37,6 @@ BEGIN { { $^W = 1; } } -use strict; -use Carp; - ###################################################################### # Configuration section. @@ -100,19 +101,20 @@ my $tmp_dir = '/tmp'; chdir($tmp_dir) or die "$0: cannot chdir `$tmp_dir': $!\n"; -# Figure out what files have added using svnlook. -my @files_added; +# Figure out what files have been added/property-modified using svnlook. +my @paths_to_check; +my $props_changed_re = qr/^(?:A |[U_ ]U) (.*[^\/])$/; foreach my $line (&read_from_process($svnlook, 'changed', $repos, '-t', $txn)) { - # Add only files that were added to @files_added - if ($line =~ /^A. (.*[^\/])$/) + # Add only files that were added/property-modified to @paths_to_check + if ($line =~ /$props_changed_re/) { - push(@files_added, $1); + push(@paths_to_check, $1); } } my @errors; -foreach my $path ( @files_added ) +foreach my $path ( @paths_to_check ) { my $mime_type; my $eol_style; @@ -183,8 +185,8 @@ if (@errors) join("\n", @errors), "\n\n", <