App-GitGot
view release on metacpan or search on metacpan
bin/git-got view on Meta::CPAN
=head1 VERSION
version 1.339
=head1 SYNOPSIS
cd some/proj/in/a/vcs
got add
# answer prompts for various information
# or run with '-D' to take all defaults
# show managed repositories
got list
got ls
# run a command in selected repositories
got do --tag perl --command "ls t/"
# show managed repositories sorted by path (default = sort by name)
got ls -p
# remove repo #1 from the list
got remove 1
# remove repo named 'bar' from the list
got remove bar
# remove all repos tagged 'foo' without confirmation prompts
got rm -f -t foo
# remove repo #3 without confirmation prompts and be noisy about it
got rm -f -v 3
# show status (up-to-date, dirty, etc.) for all repos
got status
# show status for repo #3
got st 3
# fetch upstream for all repositories
got fetch
bin/git-got view on Meta::CPAN
# spawn a subshell with working directory set to 'path' of repo foo
got cd foo
# or use 'tmux' subcommand to open a new tmux window instead
got tmux 1
got tmux foo
# N.b., 'tmux' will reuse an existing window if one is open
# checkout a local working copy of a repo and add it to your list of repos.
# will prompt for info on what to name repo, tags, etc.
got clone <git/http/ssh url>
# As above, but accept defaults for all options without prompting
got clone -D <git/http/ssh url>
# fork a github repo, add it to your list of repos, and check it out in
# the current working directory
got fork https://github.com/somebodies/repo_name
# note: the default path to a repo added via 'fork' is a directory
# named 'repo_name' in the current working directory
# if you just want to fork without checking out a working copy:
=head1 VERSION
version 1.339
=head1 SYNOPSIS
cd some/proj/in/a/vcs
got add
# answer prompts for various information
# or run with '-D' to take all defaults
# show managed repositories
got list
got ls
# run a command in selected repositories
got do --tag perl --command "ls t/"
# show managed repositories sorted by path (default = sort by name)
got ls -p
# remove repo #1 from the list
got remove 1
# remove repo named 'bar' from the list
got remove bar
# remove all repos tagged 'foo' without confirmation prompts
got rm -f -t foo
# remove repo #3 without confirmation prompts and be noisy about it
got rm -f -v 3
# show status (up-to-date, dirty, etc.) for all repos
got status
# show status for repo #3
got st 3
# fetch upstream for all repositories
got fetch
# spawn a subshell with working directory set to 'path' of repo foo
got cd foo
# or use 'tmux' subcommand to open a new tmux window instead
got tmux 1
got tmux foo
# N.b., 'tmux' will reuse an existing window if one is open
# checkout a local working copy of a repo and add it to your list of repos.
# will prompt for info on what to name repo, tags, etc.
got clone <git/http/ssh url>
# As above, but accept defaults for all options without prompting
got clone -D <git/http/ssh url>
# fork a github repo, add it to your list of repos, and check it out in
# the current working directory
got fork https://github.com/somebodies/repo_name
# note: the default path to a repo added via 'fork' is a directory
# named 'repo_name' in the current working directory
# if you just want to fork without checking out a working copy:
lib/App/GitGot/Command.pm view on Meta::CPAN
sub max_length_of_an_active_repo_label {
my( $self ) = @_;
my $sort_key = $self->by_path ? 'path' : 'name';
return max ( map { length $_->$sort_key } $self->active_repos);
}
sub prompt_yn {
my( $self , $message ) = @_;
printf '%s [y/N]: ' , $message;
chomp( my $response = <STDIN> );
return lc($response) eq 'y';
}
sub search_repos {
my $self = shift;
lib/App/GitGot/Command.pm view on Meta::CPAN
=head2 local_repo
Checks to see if $CWD is inside a Git repo managed by Got, and returns the
corresponding L<App::GitGot::Repo> object if it is.
=head2 max_length_of_an_active_repo_label
Returns the length of the longest name in the active repo list.
=head2 prompt_yn
Takes a message argument and uses it to prompt for a yes/no response.
Response defaults to 'no'.
=head2 search_repos
Returns a L<App::GitGot::Repositories> object containing all repos managed by
Got.
=head2 write_config
lib/App/GitGot/Command/add.pm view on Meta::CPAN
unless ( -e "$path/.git" ) {
say STDERR "ERROR: Non-git repos not supported at this time.";
exit(1);
}
my( $repo, $type ) = $self->_init_for_git( $path );
# if 'defaults' option is true, tell IO::Prompt::Simple to use default choices
$ENV{PERL_IOPS_USE_DEFAULT} = $self->opt->defaults;
return unless prompt( "\nAdd repository at '$path'? ", { yn => 1, default => 'y' } );
my $name = prompt( 'Name? ', lc path( $path )->basename );
my $remote;
if ( 1 == scalar keys %$repo ) { # one remote? No choice
($remote) = values %$repo;
}
else {
$remote = prompt( 'Tracking remote? ', {
anyone => $repo,
verbose => 1,
maybe default => ( $repo->{$self->opt->origin} && $self->opt->origin ),
});
}
return App::GitGot::Repo::Git->new({ entry => {
type => $type,
path => "$path", # Path::Tiny to string coercion
name => $name,
repo => $remote,
maybe tags => ( join ' ', prompt( 'Tags? ', join ' ', @{$self->tags||[]} )),
}});
}
sub _init_for_git {
my( $self, $path ) = @_;
### FIXME probably should have some error handling here...
my $cfg = Config::INI::Reader->read_file("$path/.git/config");
my %remotes = pairmap { $a =~ /remote "(.*?)"/ ? ( $1 => $b->{url} ) : () } %$cfg;
lib/App/GitGot/Command/clone.pm view on Meta::CPAN
use App::GitGot -command;
use App::GitGot::Repo::Git;
use Moo;
extends 'App::GitGot::Command';
use namespace::autoclean;
sub options {
my( $class , $app ) = @_;
return (
[ 'defaults|D' => 'use the default choices for all prompts' ] ,
[ 'recursive|r' => 'clone submodules recursively' => { default => 0 } ],
);
}
sub _use_io_page { 0 }
sub _execute {
my ( $self, $opt, $args ) = @_;
my ( $repo , $path ) = @$args;
lib/App/GitGot/Command/clone.pm view on Meta::CPAN
my $name = path( $repo )->basename;
$name =~ s/.git$//;
$path //= "$cwd/$name";
$path = path( $path )->absolute;
my $tags;
unless ( $self->opt->defaults ) {
$name = prompt( 'Name: ' , $name );
while() {
$path = prompt( 'Path: ' , $path );
last if not path($path)->exists;
say "can't clone into '$path': directory already exists";
}
$tags = prompt( 'Tags: ' , $tags );
}
my $new_entry = App::GitGot::Repo::Git->new({ entry => {
repo => $repo,
name => $name,
type => 'git',
path => $path,
}});
$new_entry->{tags} = $tags if $tags;
lib/App/GitGot/Command/clone.pm view on Meta::CPAN
App::GitGot::Command::clone - clone a remote repo and add it to your config
=head1 VERSION
version 1.339
=head1 SYNOPSIS
# clone repository and add to got config
$ got clone <git repo url>
# prompts for name, path, tags, etc.
# clone repository and add to got config
# using defaults for all prompts
$ got clone -D <git repo url>
# recursively clone the submodules as well
$ got clone -r <git repo url>
=head1 AUTHOR
John SJ Anderson <john@genehack.org>
=head1 COPYRIGHT AND LICENSE
lib/App/GitGot/Command/mux.pm view on Meta::CPAN
die "-e and -s are mutually exclusive"
if $self->opt->exec and $self->opt->session;
my @repos = $self->opt->dirty ? $self->_get_dirty_repos() : $self->active_repos();
my $target = $self->opt->session ? 'session' : 'window';
if ( @repos >= 25 ) {
my $repo_count = scalar @repos;
return unless
prompt( "\nYou're about to open $repo_count ${target}s - you sure about that? ", { yn => 1, default => 'n' } );
}
REPO: foreach my $repo ( @repos ) {
# is it already opened?
my %windows = reverse map { /^(\d+):::(\S+)/ }
split "\n", `tmux list-$target -F"#I:::#W"`;
if( my $window = $windows{$repo->name} ) {
if ($self->opt->session) {
system 'tmux', 'switch-client', '-t' => $window;
lib/App/GitGot/Command/remove.pm view on Meta::CPAN
}
my @new_repo_list;
REPO: for my $repo ( $self->all_repos ) {
my $number = $repo->number;
if ( any { $number == $_->number } $self->active_repos ) {
my $name = $repo->label;
if ( $self->opt->force or $self->prompt_yn( "got rm: remove '$name'?" )) {
say "Removed repo '$name'" if $self->verbose;
next REPO;
}
}
push @new_repo_list , $repo;
}
$self->set_full_repo_list( \@new_repo_list );
$self->write_config();
}
( run in 0.753 second using v1.01-cache-2.11-cpan-6aa56a78535 )