App-GitHub-FixRepositoryName
view release on metacpan or search on metacpan
lib/App/GitHub/FixRepositoryName.pm view on Meta::CPAN
my $url = shift;
my $repository;
eval {
$repository = App::GitHub::FindRepository->find( $url );
};
warn $@ if $@;
return $repository->url if $repository;
return $url; # Put back what we originally had
}
sub do_usage(;$) {
my $error = shift;
warn $error if $error;
warn <<'_END_';
Usage: github-fix-repository-name [...] <path>
--backup-to <directory> Backup 'config' to <directory> (default is the same directory)
--no-backup Do not make a backup first
t/01-basic.t view on Meta::CPAN
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
_END_
use Directory::Scratch;
use Path::Class;
use Digest::SHA1 qw/sha1_hex/;
sub sha1_file($) {
my $file = shift;
return sha1_hex scalar $file->slurp;
}
my $good_config = Path::Class::File->new( "t/assets/good-config" );
my $bad_config = Path::Class::File->new( "t/assets/bad-config" );
my $good_sha1 = sha1_file $good_config;
my $bad_sha1 = sha1_file $bad_config;
my ($file, $backup, %options);
%options = ( silent => 1, always_yes => 1 );
sub scratch($;$) {
my $bad_file = shift;
my $good_file = shift;
my $scratch = Directory::Scratch->new;
if ($good_file) { $good_file = $scratch->file( $good_file ); $good_file->parent->mkpath; $good_file->openw->print( scalar $good_config->slurp ) }
if ($bad_file) { $bad_file = $scratch->file( $bad_file ); $bad_file->parent->mkpath; $bad_file->openw->print( scalar $bad_config->slurp ) }
return $scratch;
}
{
my $scratch = scratch '.git/config';
( run in 0.610 second using v1.01-cache-2.11-cpan-65fba6d93b7 )