[pkg-perl-tools] 01/01: lib/Debian/PkgPerl/GitHub.pm: improve code and doc

Alex Muntada alexm-guest at moszumanska.debian.org
Sun Nov 6 19:16:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

alexm-guest pushed a commit to branch master
in repository pkg-perl-tools.

commit 51b4e287bb42959e2031ba30350624cdb0961d5d
Author: Alex Muntada <alexm at alexm.org>
Date:   Sun Nov 6 20:05:50 2016 +0100

    lib/Debian/PkgPerl/GitHub.pm: improve code and doc
    
    This issues reported by perlcritic were fixed:
    
    - add SYNOPSIS and SUBROUTINES/METHODS sections
    - end module code with a true value
    - do not export anything by default
    - clone_branch_patch_push: return explicitly
    - create_pull_request: remove conditional on return
---
 lib/Debian/PkgPerl/GitHub.pm | 29 +++++++++++++++++++++++++++--
 scripts/forward              |  2 +-
 t/github.t                   |  2 +-
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/lib/Debian/PkgPerl/GitHub.pm b/lib/Debian/PkgPerl/GitHub.pm
index 52a990e..718f6ef 100644
--- a/lib/Debian/PkgPerl/GitHub.pm
+++ b/lib/Debian/PkgPerl/GitHub.pm
@@ -8,11 +8,31 @@ use warnings;
 
 Debian::PkgPerl::GitHub - Help forwarding a bug or a patch to GitHub
 
+=head1 SYNOPSIS
+
+    $gh = Net::GitHub->new(
+        access_token => $token,
+    );
+    
+    create_fork($gh, $owner, $repo, $orgname)
+        unless fork_exists($gh, $orgname, $repo);
+    
+    clone_branch_patch_push($orgname, $repo, $branch, $patch, $comment);
+    
+    $url = create_pull_request($gh, $owner, $repo, {
+        title => $comment,
+        body  => $body,
+        head  => "$orgname:$branch",
+        base  => $base,
+    });
+
 =head1 DESCRIPTION
 
 This module exports several helpers that that provide support for
 forwarding patches to GitHub as pull requests.
 
+=head1 SUBROUTINES/METHODS
+
 =cut
 
 
@@ -20,12 +40,13 @@ use File::Temp qw(tempdir);
 use Git::Repository;
 
 use Exporter 'import';
-our @EXPORT = qw(
+our @EXPORT_OK = qw(
     fork_exists
     create_fork
     clone_branch_patch_push
     create_pull_request
 );
+our %EXPORT_TAGS = ( all => \@EXPORT_OK );
 
 =head2 fork_exists($gh, $user, $repo)
 
@@ -163,6 +184,8 @@ sub clone_branch_patch_push {
     $r->run( add => '.' );
     $r->run( commit => '-m', $comment );
     $r->run( push => 'origin', $branch );
+
+    return;
 }
 
 =head2 create_pull_request($gh, $user, $repo, $params)
@@ -201,7 +224,7 @@ sub create_pull_request {
 
     $gh->pull_request->set_default_user_repo($user, $repo);
     my $pull = $gh->pull_request->create_pull($params);
-    return $pull->{html_url} if $pull;
+    return $pull && $pull->{html_url};
 }
 
 =head1 LICENSE AND COPYRIGHT
@@ -219,3 +242,5 @@ by the Free Software Foundation; or the Artistic License.
 See http://dev.perl.org/licenses/ for more information.
 
 =cut
+
+1;
diff --git a/scripts/forward b/scripts/forward
index b3f2b65..a1b83b0 100755
--- a/scripts/forward
+++ b/scripts/forward
@@ -16,7 +16,7 @@ use Text::Wrap qw(wrap);
 use Proc::InvokeEditor;
 use MIME::Lite;
 use YAML::XS qw(LoadFile);
-use Debian::PkgPerl::GitHub;
+use Debian::PkgPerl::GitHub ':all';
 
 use warnings;
 use strict;
diff --git a/t/github.t b/t/github.t
index 3bb91f8..467cca0 100644
--- a/t/github.t
+++ b/t/github.t
@@ -20,7 +20,7 @@ BEGIN {
 }
 
 use Test::RequiresInternet ( 'github.com' => 22 );
-use Debian::PkgPerl::GitHub;
+use Debian::PkgPerl::GitHub ':all';
 
 # Defaults
 my $owner   = 'alexm';

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