diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 00:39:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 00:39:23 +0000 |
commit | e3b16b3856bdd5c1645f4609d61bf5a16c026930 (patch) | |
tree | d9def3b6f6f46b166fc6f516775350fedeefbef6 /lib/Devscripts/Salsa/checkout.pm | |
parent | Initial commit. (diff) | |
download | devscripts-6004446df3c0451f98e22b2e497a8cacf665deb2.tar.xz devscripts-6004446df3c0451f98e22b2e497a8cacf665deb2.zip |
Adding upstream version 2.19.5+deb10u1.upstream/2.19.5+deb10u1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/Devscripts/Salsa/checkout.pm')
-rw-r--r-- | lib/Devscripts/Salsa/checkout.pm | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/Devscripts/Salsa/checkout.pm b/lib/Devscripts/Salsa/checkout.pm new file mode 100644 index 0000000..c68653d --- /dev/null +++ b/lib/Devscripts/Salsa/checkout.pm @@ -0,0 +1,52 @@ +# Clones or updates a repository using gbp +# TODO: git-dpm ? +package Devscripts::Salsa::checkout; + +use strict; +use Devscripts::Output; +use Devscripts::Utils; +use Dpkg::IPC; +use Moo::Role; + +with "Devscripts::Salsa::Repo"; + +sub checkout { + my ($self, @repos) = @_; + unless (@repos or $self->config->all) { + ds_warn "Usage $0 checkout <names>"; + return 1; + } + if (@repos and $self->config->all) { + ds_warn "--all with a reponame makes no sense"; + return 1; + } + # If --all is asked, launch all projects + @repos = map { $_->[1] } $self->get_repo(0, @repos) unless (@repos); + my $cdir = `pwd`; + chomp $cdir; + foreach (@repos) { + my $path = $self->project2path($_); + s#.*/##; + if (-d $_) { + chdir $_; + ds_verbose "Updating existing checkout in $_"; + spawn( + exec => ['gbp', 'pull', '--pristine-tar'], + wait_child => 1 + ); + chdir $cdir; + } else { + spawn( + exec => [ + 'gbp', 'clone', + '--all', $self->config->git_server_url . $path . ".git" + ], + wait_child => 1, + ); + ds_warn "$_ ready in $_/"; + } + } + return 0; +} + +1; |