Ho un problema con il mio hook pre-commit.hook pre-commit in svn: non può essere tradotto dalla locale nativa in UTF-8
Questo gancio verifica se un file è bloccato quando l'utente esegue il commit. Quando si verifica una condizione non valida, dovrebbe emettere che un altro utente sta bloccando questo file o se nessuno sta bloccando, dovrebbe mostrare "non stai bloccando questo messaggio (nome del file)". L'errore si verifica quando il nome del file ha caratteri latini come "ç" e la tartaruga mi mostra questo nell'output.
commit falliti (Seguono dettagli): commit bloccati pre-commit hook (codice di uscita 1) con uscita: [. Uscita Erro non può essere tradotto dal locale nativo UTF-8]
Do sai come posso risolvere questo?
Grazie,
Alexandre
mio script di shell è qui:
#!/bin/sh
REPOS="$1"
TXN="$2"
export LANG="en_US.UTF-8"
/app/svn/hooks/ensure-has-need-lock.pl "$REPOS" "$TXN"
if [ $? -ne 0 ]; then exit 1; fi
exit 0
E il mio Perl è qui:
!/usr/bin/env perl
#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;
&usage unless @ARGV == 2;
my $repos = shift;
my $txn = shift;
my $svnlook = "/usr/local/bin/svnlook";
my $user;
my $ok = 1;
foreach my $program ($svnlook)
{
if (-e $program)
{
unless (-x $program)
{
warn "$0: required program $program' is not executable, ",
"edit $0.\n";
$ok = 0;
}
}
else
{
warn "$0: required program $program' does not exist, edit $0.\n";
$ok = 0;
}
}
exit 1 unless $ok;
unless (-e $repos){
&usage("$0: repository directory $repos' does not exist.");
}
unless (-d $repos){
&usage("$0: repository directory $repos' is not a directory.");
}
foreach my $user_tmp (&read_from_process($svnlook, 'author', $repos, '-t', $txn))
{
$user = $user_tmp;
}
my @errors;
foreach my $transaction (&read_from_process($svnlook, 'changed', $repos, '-t', $txn)){
if ($transaction =~ /^U. (.*[^\/])$/){
my $file = $1;
my $err = 0;
foreach my $locks (&read_from_process($svnlook, 'lock', $repos, $file)){
$err = 1;
if($locks=~ /Owner: (.*)/){
if($1 != $user){
push @errors, "$file : You are not locking this file!";
}
}
}
if($err==0){
push @errors, "$file : You are not locking this file!";
}
}
elsif($transaction =~ /^D. (.*[^\/])$/){
my $file = $1;
my $tchan = &read_from_process($svnlook, 'lock', $repos, $file);
foreach my $locks (&read_from_process($svnlook, 'lock', $repos, $file)){
push @errors, "$1 : cannot delete locked Files";
}
}
elsif($transaction =~ /^A. (.*[^\/])$/){
my $needs_lock;
my $path = $1;
foreach my $prop (&read_from_process($svnlook, 'proplist', $repos, '-t', $txn, '--verbose', $path)){
if ($prop =~ /^\s*svn:needs-lock : (\S+)/){
$needs_lock = $1;
}
}
if (not $needs_lock){
push @errors, "$path : svn:needs-lock is not set. Pleas ask TCC for support.";
}
}
}
if (@errors)
{
warn "$0:\n\n",
join("\n", @errors), "\n\n";
exit 1;
}
else
{
exit 0;
}
sub usage
{
warn "@_\n" if @_;
die "usage: $0 REPOS TXN-NAME\n";
}
sub safe_read_from_pipe
{
unless (@_)
{
croak "$0: safe_read_from_pipe passed no arguments.\n";
}
print "Running @_\n";
my $pid = open(SAFE_READ, '-|');
unless (defined $pid)
{
die "$0: cannot fork: $!\n";
}
unless ($pid)
{
open(STDERR, ">&STDOUT")
or die "$0: cannot dup STDOUT: $!\n";
exec(@_)
or die "$0: cannot exec @_': $!\n";
}
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\n";
}
if (wantarray)
{
return ($result, @output);
}
else
{
return $result;
}
}
sub read_from_process
{
unless (@_)
{
croak "$0: read_from_process passed no arguments.\n";
}
my ($status, @output) = &safe_read_from_pipe(@_);
if ($status)
{
if (@output)
{
die "$0: @_' failed with this output:\n", join("\n", @output), "\n";
}
else
{
die "$0: @_' failed with no output.\n";
}
}
else
{
return @output;
}
}
Penso che sarebbe utile vedere anche l'origine dello script perl. Perché pensi che l'errore non sia lì? – amarillion
Penso che l'errore sia in shell o in tartaruga (non lo so) se la shell contiene solo questo: echo "testç" 1> & 2 si verifica lo stesso errore. Ma inserirò il mio codice perl. –
Sto cercando questa soluzione per 5 giorni e non riesco a trovarla. Forse questo è un bug o qualcosa del genere. Se qualcuno ha qualche idea su cosa sta succedendo, o se si tratta di un bug o se è successo con qualcuno. Grazie –