[pkg-perl-tools] 02/05: dpt-salsa: activate and improve user functions

gregor herrmann gregoa at debian.org
Sat Jan 27 21:58:41 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 6156528e8669a2c5eb83c72e97afa0cc4c7e9e3a
Author: gregor herrmann <gregoa at debian.org>
Date:   Sat Jan 27 22:49:17 2018 +0100

    dpt-salsa: activate and improve user functions
    
    Gbp-Dch: Ignore
---
 debian/control |  2 ++
 scripts/salsa  | 45 +++++++++++++++++++++++++++------------------
 2 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/debian/control b/debian/control
index b97c341..8adc4cb 100644
--- a/debian/control
+++ b/debian/control
@@ -30,6 +30,7 @@ Build-Depends-Indep: dpkg-dev (>= 1.17.0),
                      libtest-mockmodule-perl,
                      libtest-pod-perl,
                      libtest-spelling-perl,
+                     libutf8-all-perl,
                      libwww-mechanize-perl,
                      libyaml-libyaml-perl,
                      lintian (>= 2.5.28~),
@@ -61,6 +62,7 @@ Depends: ${misc:Depends},
          libparse-debianchangelog-perl,
          libproc-invokeeditor-perl,
          librt-client-rest-perl,
+         libutf8-all-perl,
          lintian (>= 2.5.28~),
          openssh-client | ssh-client,
          pristine-tar,
diff --git a/scripts/salsa b/scripts/salsa
index 448e706..a55c78c 100755
--- a/scripts/salsa
+++ b/scripts/salsa
@@ -8,9 +8,7 @@ use Pod::Usage qw( pod2usage );
 use GitLab::API::v4;
 use GitLab::API::v4::Constants qw( :all );
 use JSON;
-
-#use utf8::all;   # XXX
-#use App::Cmd;    # XXX
+use utf8::all;
 
 # config
 ## defaults
@@ -61,6 +59,23 @@ my $api = GitLab::API::v4->new(
     private_token => $config{private_token},
 );
 
+# data
+my %levels_name = (
+    guest     => $GITLAB_ACCESS_LEVEL_GUEST,
+    reporter  => $GITLAB_ACCESS_LEVEL_REPORTER,
+    developer => $GITLAB_ACCESS_LEVEL_DEVELOPER,
+    master    => $GITLAB_ACCESS_LEVEL_MASTER,
+    owner     => $GITLAB_ACCESS_LEVEL_OWNER,
+);
+
+my %levels_code = (
+    $GITLAB_ACCESS_LEVEL_GUEST     => 'guest',
+    $GITLAB_ACCESS_LEVEL_REPORTER  => 'reporter',
+    $GITLAB_ACCESS_LEVEL_DEVELOPER => 'developer',
+    $GITLAB_ACCESS_LEVEL_MASTER    => 'master',
+    $GITLAB_ACCESS_LEVEL_OWNER     => 'owner',
+);
+
 # run command
 if ( $command eq 'version' ) {
     version();
@@ -120,17 +135,9 @@ sub adduser {
 
     my $user_id = user2userid($user);
 
-    my %levels = (
-        guest     => $GITLAB_ACCESS_LEVEL_GUEST,
-        reporter  => $GITLAB_ACCESS_LEVEL_REPORTER,
-        developer => $GITLAB_ACCESS_LEVEL_DEVELOPER,
-        master    => $GITLAB_ACCESS_LEVEL_MASTER,
-        owner     => $GITLAB_ACCESS_LEVEL_OWNER,
-    );
-    my $access_level = $levels{ lc($level) };
+    my $access_level = $levels_name{ lc($level) };
     die "Unknown access level '$level'." unless $access_level;
 
-    ...;
     $api->add_group_member( $config{'perl_team_modules_id'},
         { user_id => $user_id, access_level => $access_level } );
 }
@@ -140,21 +147,23 @@ sub removeuser {
     my ($user) = @args;
     die 'Required parameter username|userid missing.' unless $user;
     my $user_id = user2userid($user);
-    ...;
     $api->remove_group_member( $config{'perl_team_modules_id'}, $user_id );
 }
 
 ## listmembers()
 sub listmembers {
-    my $members = $api->group_members( $config{'perl_team_modules_id'} );
-    ...;
+    my $members
+        = $api->paginator( 'group_members', $config{'perl_team_modules_id'} )
+        ->all();
     foreach ( @{$members} ) {
         if ( $opts{json} ) {
             say prettyjson($_);
         } else {
-            say "Id:       " . $_->{id};
-            say "Username: " . $_->{username};
-            say "Name:     " . $_->{name};
+            my $access_level = $levels_code{ $_->{access_level} };
+            say "Id:           " . $_->{id};
+            say "Username:     " . $_->{username};
+            say "Name:         " . $_->{name};
+            say "Access level: " . $access_level;
         }
     }
 }

-- 
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