[pkg-perl-tools] 01/01: dpt-salsa: add pushrepo method, like dpt-alioth-repo for new packages
gregor herrmann
gregoa at debian.org
Thu Feb 1 23:48:00 UTC 2018
This is an automated email from the git hooks/post-receive script.
gregoa pushed a commit to branch master
in repository pkg-perl-tools.
commit ed8d9638a0c1552772cbaf9dc953d0569428a6e6
Author: gregor herrmann <gregoa at debian.org>
Date: Fri Feb 2 00:46:52 2018 +0100
dpt-salsa: add pushrepo method, like dpt-alioth-repo for new packages
Gbp-Dch: Ignore
---
scripts/salsa | 48 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 44 insertions(+), 4 deletions(-)
diff --git a/scripts/salsa b/scripts/salsa
index 88d2094..85493c8 100755
--- a/scripts/salsa
+++ b/scripts/salsa
@@ -7,6 +7,7 @@ use Getopt::Long;
use Pod::Usage qw( pod2usage );
use GitLab::API::v4;
use GitLab::API::v4::Constants qw( :all );
+use Git;
use JSON;
use utf8::all;
@@ -104,6 +105,8 @@ if ( $command eq 'version' ) {
listrepos();
} elsif ( $command eq 'createrepo' ) {
createrepo();
+} elsif ( $command eq 'pushrepo' ) {
+ pushrepo();
} elsif ( $command eq 'configurerepo' ) {
configurerepo();
} elsif ( $command eq 'changerepo' ) {
@@ -229,7 +232,7 @@ sub listrepos {
## createrepo()
sub createrepo {
- my ($reponame) = @args;
+ my ($reponame) = shift || @args;
die 'Required parameter repositoryname missing.' unless $reponame;
my $repo = $api->create_project(
@@ -239,12 +242,44 @@ sub createrepo {
visibility => 'public',
}
);
- configurerepo();
+ configurerepo( $repo->{id} );
+}
+
+## pushrepo()
+sub pushrepo {
+ my $pkg = qx/dh_testdir && dpkg-parsechangelog --show-field Source/;
+ die "Can't find the name of this source package." unless $pkg;
+ chomp $pkg;
+
+ my $localrepo = Git->repository();
+ my %remotes = map { my ( $name, $url ) = split ' '; $name => $url; }
+ $localrepo->command( 'remote', '--verbose', 'show' );
+ my $salsaurl
+ = 'git at salsa.debian.org:'
+ . $config{perl_team_modules_packages_path}
+ . "/$pkg.git";
+ if ( !$remotes{'origin'} ) {
+ $localrepo->command( 'remote', 'add', 'origin', $salsaurl );
+ } elsif ( $remotes{'origin'}
+ !~ m!^git\@salsa.debian.org:$config{perl_team_modules_packages_path}/$pkg.git$!
+ )
+ {
+ $localrepo->command( 'remote', 'set-url', 'origin', $salsaurl );
+ }
+
+ createrepo($pkg)
+ unless $api->project(
+ $config{perl_team_modules_packages_path} . '/' . $pkg );
+
+ # or --mirror instead of the two? also pushes origin/ branches
+ $localrepo->command( 'push', '--all', '--verbose', '--set-upstream',
+ 'origin' );
+ $localrepo->command( 'push', '--tags', '--verbose', 'origin' );
}
## configurerepo()
sub configurerepo {
- my ($repo) = @args;
+ my ($repo) = shift || @args;
die 'Required parameter reponame|repoid missing.'
unless ( $repo or $opts{all} );
my @repoids = $opts{all} ? listrepos() : $repo;
@@ -368,7 +403,7 @@ sub reponame2repopath {
sub repo2repopath {
my $repo = shift;
return $repo if $repo =~ /^\d+$/;
- return reponame2repopath($repo) if $repo =~ /^\w+$/;
+ return reponame2repopath($repo) if $repo =~ /^[\w-]+$/;
die
"Parameter '$repo' doesn't look like a repositoryid or a repositoryname.";
}
@@ -415,6 +450,11 @@ Required.
=back
+=head3 I<pushrepo>
+
+Creates a new repository in the I<modules> subgroup and pushes the local
+repository.
+
=head3 I<configurerepo> I<repositoryid|repositoryname>
Sets up the default webhooks and services for one repository.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git
More information about the Pkg-perl-cvs-commits
mailing list