summaryrefslogtreecommitdiffstats
path: root/lib/Devscripts/Salsa/checkout.pm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:01:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:01:11 +0000
commit3be121a05dcd170854a8dac6437b29f297a6ff4e (patch)
tree05cf57183f5a23394eca11b00f97a74a5dfdf79d /lib/Devscripts/Salsa/checkout.pm
parentInitial commit. (diff)
downloaddevscripts-3be121a05dcd170854a8dac6437b29f297a6ff4e.tar.xz
devscripts-3be121a05dcd170854a8dac6437b29f297a6ff4e.zip
Adding upstream version 2.23.4+deb12u1.upstream/2.23.4+deb12u1upstream
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.pm79
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/Devscripts/Salsa/checkout.pm b/lib/Devscripts/Salsa/checkout.pm
new file mode 100644
index 0000000..c3b5fe5
--- /dev/null
+++ b/lib/Devscripts/Salsa/checkout.pm
@@ -0,0 +1,79 @@
+# 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 or $self->config->all_archived) {
+ ds_warn "Usage $0 checkout <--all|--all-archived|names>";
+ return 1;
+ }
+ if (@repos and $self->config->all) {
+ ds_warn "--all with a reponame makes no sense";
+ return 1;
+ }
+ if (@repos and $self->config->all_archived) {
+ ds_warn "--all-archived 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;
+ my $res = 0;
+ 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,
+ nocheck => 1,
+ );
+ if ($?) {
+ if ($self->config->no_fail) {
+ print STDERR "gbp pull fails in $_, "
+ . "continuing since --no-fail is set\n";
+ $res++;
+ } else {
+ ds_warn "gbp pull failed in $_\n";
+ return 1;
+ }
+ }
+ chdir $cdir;
+ } else {
+ spawn(
+ exec => [
+ 'gbp', 'clone',
+ '--all', $self->config->git_server_url . $path . ".git"
+ ],
+ wait_child => 1,
+ nocheck => 1,
+ );
+ if ($?) {
+ if ($self->config->no_fail) {
+ print STDERR "gbp clone fails in $_, "
+ . "continuing since --no-fail is set\n";
+ $res++;
+ } else {
+ ds_warn "gbp clone failed for $_\n";
+ return 1;
+ }
+ }
+ ds_warn "$_ ready in $_/";
+ }
+ }
+ return $res;
+}
+
+1;