From: Vincent Pit Date: Sun, 4 Jan 2009 15:14:35 +0000 (+0100) Subject: @ wasn't such a good idea for the escape character. Let's use % instead X-Git-Tag: v0.06~2 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=9fa31a712601956c8e4c34cbfc0af111346920c3;p=perl%2Fmodules%2Frgit.git @ wasn't such a good idea for the escape character. Let's use % instead --- diff --git a/bin/rgit b/bin/rgit index 6e3e04f..2b86e4d 100755 --- a/bin/rgit +++ b/bin/rgit @@ -149,39 +149,39 @@ Moreover, those formats are substituted in the arguments before running the comm =item * -C<@n> with the current repository name. +C<%n> with the current repository name. =item * -C<@g> with the relative path (based from the root directory) to the current repository. +C<%g> with the relative path (based from the root directory) to the current repository. =item * -C<@G> with the absolute path to the current repository. +C<%G> with the absolute path to the current repository. =item * -C<@w> with the relative path (based from the root directory) to the current repository's working directory. +C<%w> with the relative path (based from the root directory) to the current repository's working directory. =item * -C<@W> with the absolute path to the current repository's working directory. +C<%W> with the absolute path to the current repository's working directory. =item * -C<@b> with a "bareified" relative path, i.e. C<@g> if this is a bare repository, and C<@w.git> otherwise. +C<%b> with a "bareified" relative path, i.e. C<%g> if this is a bare repository, and C<%w.git> otherwise. =item * -C<@B> with an absolute version of the "bareified" path. +C<%B> with an absolute version of the "bareified" path. =item * -C<@R> with the absolute path to the root directory. +C<%R> with the absolute path to the root directory. =item * -C<@@> with a bare C<@>. +C<%%> with a bare C<%>. =back @@ -235,11 +235,11 @@ Execute C on all the repositories below the current directory : Tag all the repositories with their name : - rgit tag @n + rgit tag %n Add a remote to all repositories in "/foo/bar" to their bare counterpart in C on F : - GIT_DIR="/foo/bar" rgit remote add host git://host/qux/@b + GIT_DIR="/foo/bar" rgit remote add host git://host/qux/%b =head1 DEPENDENCIES diff --git a/lib/App/Rgit/Repository.pm b/lib/App/Rgit/Repository.pm index dbdfe73..8a915b0 100644 --- a/lib/App/Rgit/Repository.pm +++ b/lib/App/Rgit/Repository.pm @@ -119,7 +119,7 @@ sub _abs2rel { } my %escapes = ( - '@' => sub { '@' }, + '%' => sub { '%' }, 'n' => sub { shift->name }, 'g' => sub { _abs2rel(shift->repo, shift->root) }, 'G' => sub { shift->repo }, @@ -141,7 +141,7 @@ sub run { return unless $conf->isa('App::Rgit::Config'); my @args = @_; unless ($self->fake) { - s/@($e)/$escapes{$1}->($self, $conf)/eg for @args; + s/%($e)/$escapes{$1}->($self, $conf)/eg for @args; } unshift @args, $conf->git; $conf->info('Executing "', join(' ', @args), '" into ', $self->work, "\n"); diff --git a/t/20-each.t b/t/20-each.t index a5d47c2..5c337e7 100644 --- a/t/20-each.t +++ b/t/20-each.t @@ -89,7 +89,7 @@ is(grep({ ref eq 'ARRAY' } @expected), 3, 'all of them are array references'); @$_, map({ catdir($tmpdir, $_) } @{$_}[1 .. 3]), $tmpdir, - '@n', '@x' + '%n', '%x' ], @expected; sub try { @@ -99,7 +99,7 @@ sub try { git => abs_path('t/bin/git'), root => $tmpdir, cmd => $cmd, - args => [ abs_path($filename), $cmd, qw/@n @g @w @b @G @W @B @R @@n @x/ ], + args => [ abs_path($filename), $cmd, qw/%n %g %w %b %G %W %B %R %%n %x/ ], policy => $policy, ); isnt($ar, undef, "each $cmd has a defined object"); diff --git a/t/21-once.t b/t/21-once.t index e61e81c..65accd2 100644 --- a/t/21-once.t +++ b/t/21-once.t @@ -11,7 +11,7 @@ use Test::More tests => 9 * 5; use App::Rgit; my @expected = ( - ([ [ qw/@n @g @w @b @@/ ] ]) x 5 + ([ [ qw/%n %g %w %b %%/ ] ]) x 5 ); local $ENV{GIT_DIR} = 't'; @@ -23,7 +23,7 @@ for my $cmd (qw/daemon gui help init version/) { git => $ENV{GIT_EXEC_PATH}, root => $ENV{GIT_DIR}, cmd => $cmd, - args => [ abs_path($filename), $cmd, qw/@n @g @w @b @@/ ] + args => [ abs_path($filename), $cmd, qw/%n %g %w %b %%/ ] ); isnt($ar, undef, "once $cmd has a defined object"); my $exit = $ar->run; @@ -31,7 +31,7 @@ for my $cmd (qw/daemon gui help init version/) { my @lines = sort split /\n/, do { local $/; <$fh> }; is(@lines, 1, "once $cmd visited only one repo"); my $r = [ split /\|/, defined $lines[0] ? $lines[0] : '' ]; - my $e = [ $cmd, qw/@n @g @w @b @@/ ]; + my $e = [ $cmd, qw/%n %g %w %b %%/ ]; s/[\r\n]*$// for @$r; is($r->[$_], $e->[$_], "once $cmd argument $_ is ok") for 0 .. 5;