App-GitGot
view release on metacpan or search on metacpan
lib/App/GitGot/Command.pm view on Meta::CPAN
$self->_git_clone_or_callback( $entry ,
sub {
my( $msg , $entry ) = @_;
my @o = $entry->fetch;
# "git fetch" doesn't output anything to STDOUT only STDERR
my @err = @{ $entry->_wrapper->ERR };
# If something was updated then STDERR should contain something
# similar to:
#
# From git://example.com/link-to-repo
# SHA1___..SHA1___ main -> origin/main
#
# So search for /^From / in STDERR to see if anything was outputed
if ( grep { /^From / } @err ) {
$msg .= $self->major_change('Updated');
$msg .= "\n" . join("\n",@err) unless $self->quiet;
}
elsif ( scalar @err == 0) {
# No messages to STDERR means repo was already updated
$msg .= $self->minor_change('Up to date') unless $self->quiet;
}
else {
# Something else occured (possibly a warning)
# Print STDERR and move on
$msg .= $self->warning('Problem during fetch');
$msg .= "\n" . join("\n",@err) unless $self->quiet;
}
return $msg;
lib/App/GitGot/Command.pm view on Meta::CPAN
catch { $msg = $self->error('ERROR') . "\n$_" };
return $msg
}
sub _run_git_status {
my( $self , $entry ) = @_;
my %types = (
indexed => 'Changes to be committed' ,
changed => 'Changed but not updated' ,
unknown => 'Untracked files' ,
conflict => 'Files with conflicts' ,
);
my( $msg , $verbose_msg ) = ('','');
try {
my $status = $entry->status;
if ( keys %$status ) {
$msg .= $self->warning('Dirty') . ' ';
lib/App/GitGot/Command/checkout.pm view on Meta::CPAN
}
elsif ( grep { /^Already on/ } @err ) {
# already on requested branch
$msg .= $self->minor_change('OK') unless $self->quiet;
}
elsif ( grep { /did not match/ } @o ) {
# branch doesn't exist and was not created
$msg .= $self->error('Unknown branch');
}
elsif ( scalar @o == 0 && scalar @err == 0 ) {
# No messages to STDERR means repo was already updated (or this is a test)
$msg .= $self->minor_change('OK') unless $self->quiet;
}
else {
# Something else occured (possibly a warning)
# Print STDOUT/STDERR and move on
$msg .= $self->warning('Problem during checkout');
$msg .= "\n" . join("\n", @o, @err) unless $self->quiet;
return $msg;
}
lib/App/GitGot/Command/readd.pm view on Meta::CPAN
my( $class , $app ) = @_;
return ();
}
sub _use_io_page { 0 }
sub _execute {
my ( $self, $opt, $args ) = @_;
my $max_len = $self->max_length_of_an_active_repo_label();
my $updated_config = 0;
REPO: for my $repo ( $self->active_repos ) {
next unless $repo->type eq 'git';
my $configuration_url = $repo->repo;
my( $repo_url ) = $repo->config("remote.origin.url");
if( $configuration_url ne $repo_url ) {
# do as i say, not as i do...
$repo->{repo} = $repo_url;
$updated_config = 1;
printf "Updated repo url for %-${max_len}s to %s\n", $repo->name, $repo->repo
if $self->verbose;
}
}
$self->write_config()
if $updated_config;
}
1;
__END__
=pod
=encoding UTF-8
( run in 0.258 second using v1.01-cache-2.11-cpan-05444aca049 )