Dear Subversion developers,

please apply the attached patch for the hook script check-mime-type.pl.
The patch also checks files that have their properties changed, so nobody can circumvent the policy via committing changes. I have been using it on Linux (and with additional changes on Windows) for over 6 years now.

Kind regards
Matthias Bücher


Log Message:
Check also property-modified files in hook script check-mime-type.pl

* contrib/hook-scripts/check-mime-type.pl:
  (proplist) add property-modified files for checks

Patch by: Matthias Bücher <maddes+subvers...@maddes.net>
Suggested by: Leo Davis [1]

[1] https://mail-archives.apache.org/mod_mbox/subversion-dev/201403.mbox/%3c1576503.m6xb7ud...@hurry.speechfxinc.com%3E
Index: contrib/hook-scripts/check-mime-type.pl
===================================================================
--- contrib/hook-scripts/check-mime-type.pl	(revision 1878391)
+++ contrib/hook-scripts/check-mime-type.pl	(working copy)
@@ -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
@@ -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",
 				 <<EOS;
 
-    Every added file must have the svn:mime-type property set. In
-    addition text files must have the svn:eol-style property set.
+    Every added/property-modified file must have the svn:mime-type property
+    set. In addition text files must have the svn:eol-style property set.
 
     For binary files try running
     svn propset svn:mime-type application/octet-stream path/of/file
Check also property-modified files in hook script check-mime-type.pl

* contrib/hook-scripts/check-mime-type.pl:
  (proplist) add property-modified files for checks

Patch by: Matthias Bücher <maddes+subvers...@maddes.net>
Suggested by: Leo Davis [1]

[1] 
https://mail-archives.apache.org/mod_mbox/subversion-dev/201403.mbox/%3c1576503.m6xb7ud...@hurry.speechfxinc.com%3E

Reply via email to