English 中文(简体)
Strange Behaviour of Hook 成像成像
原标题:Strange Behaviour of Hook Script commit-mime-type-check.pl on windows

I have downloaded pre-commit hook script "commit-mime-type-check.pl" from svn.apache.org I am working on windows there are only two things to change path to svnlook binary and path to temp dir.I did that. but I am getting following error

Error: Commit failed (details follow):  
Error: Commit blocked by pre-commit hook (exit code 1) with output:  
Error:  -  is not recognized as an internal or external command,  
Error: operable program or batch file.  
Error: C:vsvnRepositoriesmyprojhookslocal_commit_mime_eol_check.pl:   
Error: `C:vsvninsvnlook.exe changed C:vsvnRepositoriesmyproj -t 16-1l  failed   
Error: with no output.  
Finished!: 

我自欺欺欺人,发现失败之处。

my $pid = open(SAFE_READ,  -| );

我宣读了关于“开放”的解释:

Safe Pipe Opens Another interesting approach to IPC is making your single program go multiprocess and communicate between--or even amongst--yourselves. The open() function will accept a file argument of either "-|" or "|-" to do a very interesting thing: it forks a child connected to the filehandle you ve opened. The child is running the same program as the parent. This is useful for safely opening a file when running under an assumed UID or GID, for example. If you open a pipe to minus, you can write to the filehandle you opened and your kid will find it in his STDIN. If you open a pipe from minus, you can read from the filehandle you opened whatever your kid writes to his STDOUT.

www.un.org/Depts/DGACM/index_spanish.htm 我无法理解的是,这是由于不兼容或什么。 由于最初是用黑体字书写的,而且对于管道和内部程序通信来说,这非常丰富。 在我总是发现窗口差的地方。 (对任何人不构成犯罪。) 这是我个人的情感。 让我们回到这个专题。 我期待着所有野心建议。 我不寻求固定办法,但如果我能找到,我将不胜感激。

我尝试了一切,但最后我却试图把这个问题推向另一个问题。 http://jasig.275507.n4.nabble.com/pre-commit-hook-re-svn-mime-type-preventing-commit-td1572805.html” rel=“nofollow” 。 那么,我再说不了。

以下是你参考的文字。

#!/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.
#
# Usage: commit-mime-type-check.pl REPOS TXN-NAME
# ====================================================================
# Most of commit-mime-type-check.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.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at http://subversion.tigris.org/license.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://subversion.tigris.org/.
# ====================================================================

# Turn on warnings the best way depending on the Perl version.
BEGIN {
  if ( $] >= 5.006_000)
    { require warnings; import warnings; }
  else
    { $^W = 1; }
}

use strict;
use Carp;


######################################################################
# Configuration section.

# Svnlook path.
my $svnlook = "/usr/bin/svnlook";

# Since the path to svnlook depends upon the local installation
# preferences, check that the required program exists to insure that
# the administrator has set up the script properly.
{
  my $ok = 1;
  foreach my $program ($svnlook)
    {
      if (-e $program)
        {
          unless (-x $program)
            {
              warn "$0: required program `$program  is not executable, ",
                   "edit $0.
";
              $ok = 0;
            }
        }
      else
        {
          warn "$0: required program `$program  does not exist, edit $0.
";
          $ok = 0;
        }
    }
  exit 1 unless $ok;
}

######################################################################
# Initial setup/command-line handling.

&usage unless @ARGV == 2;

my $repos        = shift;
my $txn          = shift;

unless (-e $repos)
  {
    &usage("$0: repository directory `$repos  does not exist.");
  }
unless (-d $repos)
  {
    &usage("$0: repository directory `$repos  is not a directory.");
  }

# Define two constant subroutines to stand for read-only or read-write
# access to the repository.
sub ACCESS_READ_ONLY  () {  read-only  }
sub ACCESS_READ_WRITE () {  read-write  }


######################################################################
# Harvest data using svnlook.

# Change into /tmp so that svnlook diff can create its .svnlook
# directory.
my $tmp_dir =  /tmp ;
chdir($tmp_dir)
  or die "$0: cannot chdir `$tmp_dir : $!
";

# Figure out what files have added using svnlook.
my @files_added;
foreach my $line (&read_from_process($svnlook,  changed , $repos,  -t , $txn))
  {
        # Add only files that were added to @files_added
    if ($line =~ /^A.  (.*[^/])$/)
      {
        push(@files_added, $1);
      }
  }

my @errors;
foreach my $path ( @files_added )
    {
        my $mime_type;
        my $eol_style;

        # 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))
            {
                if ($prop =~ /^s*svn:mime-type : (S+)/)
                    {
                        $mime_type = $1;
                    }
                elsif ($prop =~ /^s*svn:eol-style : (S+)/)
                    {
                        $eol_style = $1;
                    }
            }

        # Detect error conditions and add them to @errors
        if (not $mime_type)
            {
                push @errors, "$path : svn:mime-type is not set";
            }
        elsif ($mime_type =~ /^text// and not $eol_style)
            {
                push @errors, "$path : svn:mime-type=$mime_type but svn:eol-style is not set";
            }
    }

# If there are any errors list the problem files and give information
# on how to avoid the problem. Hopefully people will set up auto-props
# and will not see this verbose message more than once.
if (@errors)
  {
    warn "$0:

",
         join("
", @errors), "

",
                 <<EOS;

    Every added 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

    For text files try
    svn propset svn:mime-type text/plain path/of/file
    svn propset svn:eol-style native path/of/file

    You may want to consider uncommenting the auto-props section
    in your ~/.subversion/config file. Read the Subversion book
    (http://svnbook.red-bean.com/), Chapter 7, Properties section,
    Automatic Property Setting subsection for more help.
EOS
    exit 1;
  }
else
  {
    exit 0;
  }

sub usage
{
  warn "@_
" if @_;
  die "usage: $0 REPOS TXN-NAME
";
}

sub safe_read_from_pipe
{
  unless (@_)
    {
      croak "$0: safe_read_from_pipe passed no arguments.
";
    }
  print "Running @_
";
  my $pid = open(SAFE_READ,  -| );
  unless (defined $pid)
    {
      die "$0: cannot fork: $!
";
    }
  unless ($pid)
    {
      open(STDERR, ">&STDOUT")
        or die "$0: cannot dup STDOUT: $!
";
      exec(@_)
        or die "$0: cannot exec `@_ : $!
";
    }
  my @output;
  while (<SAFE_READ>)
    {
      chomp;
      push(@output, $_);
    }
  close(SAFE_READ);
  my $result = $?;
  my $exit   = $result >> 8;
  my $signal = $result & 127;
  my $cd     = $result & 128 ? "with core dump" : "";
  if ($signal or $cd)
    {
      warn "$0: pipe from `@_  failed $cd: exit=$exit signal=$signal
";
    }
  if (wantarray)
    {
      return ($result, @output);
    }
  else
    {
      return $result;
    }
}

sub read_from_process
  {
  unless (@_)
    {
      croak "$0: read_from_process passed no arguments.
";
    }
  my ($status, @output) = &safe_read_from_pipe(@_);
  if ($status)
    {
      if (@output)
        {
          die "$0: `@_  failed with this output:
", join("
", @output), "
";
        }
      else
        {
          die "$0: `@_  failed with no output.
";
        }
    }
  else
    {
      return @output;
    }
}
最佳回答

我一直看着这个Perl syntax,我对我说:“Wow,这是老的<>。

If you look at the Perldoc of the open function, you ll see that the two parameter argument doesn t mention what your hook script is doing. Yet, as you pointed out, perlipc does mention it.

阁下 口译人员正在对Perldoc的公开提名说明中提及的 >进行解释:

  • This is a two parameter form of the function. Thus:
    • The first argument is the name of the file handle.
    • The second argument is the name of the file.
  • Since the file name ends with a pipe, the rest of the file name is the name of the command to execute which to pipe though STDIN when you read from the pipe.

由于第二个论点是<条码>->->>>->>-->代码>,因此寻找一个称为<条码>的指挥系统。 <条码>-、<条码>、>开放式<>/条码>功能不全。

不知道你可以做些什么,但你可以借我的 它可以做各种各样的事情。

它可以做的事情之一是根据档案名称强制执行财产类型和价值。 举例来说,您可以把所有与<代码>相一致的文档(<>>.shsuffix to have svn:eol-type>,或与的文档(<>pdf> >suffix has svn:mime-type set to application/pdf<<>/code> 我认为,这是什么。

我只读了这个字眼,看一看我是否能够 exact弄它究竟做些什么以及它如何运作。 d 我向阿帕奇提交“固定的 h本”,但不再保留 h本。

I ve never used the open SAFE_READ, "-|" syntax before but you learn something every day. I ll have to play around with it.

问题回答

暂无回答




相关问题
Best practices for Subversion and Visual Studio projects

I ve recently started working on various C# projects in Visual Studio as part of a plan for a large scale system that will be used to replace our current system that s built from a cobbling-together ...

Changing username in SVN+SSH URI on the fly in working copy

I am using SVN+SSH to check out a working copy of repository from an SVN server on which all developers are members of a developer group and have full read/write permissions on the repository ...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

How to search for file in subversion server?

Is there a way to search for a file in a subversion repository? Something similar to Unix find command, with which I can find the location of a file in a repository. I know there is svn list, but ...