[PATCH 1/2] Fixed check-mime-type.pl so that it also works for svnlook versions from 1.7.8 (r1416637).
From: Brett Randall <javabrett_at_gmail.com>
Date: Mon, 24 Aug 2015 10:42:29 +1000
In r1416637, svnlook proplist --verbose output changed from propname : propval format, to an indented output:
Properties on ...
This change makes check-mime-type aware of both the pre 1.7.8 and 1.7.8+ formats.
Signed-off-by: Brett Randall <javabrett_at_gmail.com>
--- contrib/hook-scripts/check-mime-type.pl | 35 +++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/contrib/hook-scripts/check-mime-type.pl b/contrib/hook-scripts/check-mime-type.pl index 9ac7e8d..8789aaa 100755 --- a/contrib/hook-scripts/check-mime-type.pl +++ b/contrib/hook-scripts/check-mime-type.pl @@ -119,17 +119,40 @@ foreach my $path ( @files_added ) # Parse the complete list of property values of the file $path to extract # the mime-type and eol-style - foreach my $prop (&read_from_process($svnlook, 'proplist', $repos, '-t', - $txn, '--verbose', '--', $path)) + + my @output = &read_from_process($svnlook, 'proplist', $repos, '-t', + $txn, '--verbose', '--', $path); + my $output_line = 0; + + foreach my $prop (@output) { - if ($prop =~ /^\s*svn:mime-type : (\S+)/) + if ($prop =~ /^\s*svn:mime-type( : (\S+))?/) { - $mime_type = $1; + $mime_type = $2; + # 1.7.8 (r1416637) onwards changed the format of svnloop proplist --verbose + # from propname : propvalue format, to values in an indent list on following lines + if (not $mime_type) + { + my $next_line_pval_indented = $output[$output_line + 1]; + if ($next_line_pval_indented =~ /^\s{4}(.*)/) + { + $mime_type = $1; + } + } } - elsif ($prop =~ /^\s*svn:eol-style : (\S+)/) + elsif ($prop =~ /^\s*svn:eol-style( : (\S+))?/) { - $eol_style = $1; + $eol_style = $2; + if (not $eol_style) + { + my $next_line_pval_indented = $output[$output_line + 1]; + if ($next_line_pval_indented =~ /^\s{4}(.*)/) + { + $eol_style = $1; + } + } } + $output_line++; } # Detect error conditions and add them to @errors -- 2.5.0Received on 2015-08-24 02:42:50 CEST |
This is an archived mail posted to the Subversion Dev mailing list.
This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.