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

alexm-guest pushed a commit to branch forward-github-pr
in repository pkg-perl-tools.

commit 7a6c58caaefbed3e2e2c8129ac82f362d4ee35cc
Author: Alex Muntada <al...@alexm.org>
Date:   Fri Oct 14 20:03:39 2016 +0200

    Add support to create pull requests for patches
    
    This feature permits to create pull requests in GitHub upstreams
    instead of creating issues with the patch inlined as comments.
    
    Add this to dpt.conf:
    
        export PERL5LIB=$DPT_PACKAGES/pkg-perl-tools/lib
    
    And then "dpt forward" should find modules in lib.
    
    Lots of testing needed! This is still a work in progress.
---
 scripts/forward | 76 +++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 49 insertions(+), 27 deletions(-)

diff --git a/scripts/forward b/scripts/forward
index dd91137..b3f2b65 100755
--- a/scripts/forward
+++ b/scripts/forward
@@ -16,6 +16,7 @@ use Text::Wrap qw(wrap);
 use Proc::InvokeEditor;
 use MIME::Lite;
 use YAML::XS qw(LoadFile);
+use Debian::PkgPerl::GitHub;
 
 use warnings;
 use strict;
@@ -292,7 +293,7 @@ sub retrieve_bug_info {
 sub get_subject {
     my $default = ( $bug ? $bug_info{Subject} : $patch_info{Subject} ) // '';
     $default = "[PATCH] $default"
-        if $patch and $default !~ /\[PATCH\]/;
+        if $patch and $default !~ /\[PATCH\]/ and $opt_tracker ne 'github';
 
     my $term = Term::ReadLine->new('forward');
 
@@ -402,8 +403,6 @@ sub prepare_body {
     elsif ($patch) {
         # patch but no bug
 
-        my $pre = ( $opt_tracker eq 'github' ) ? '    ' : '';
-
         $body
             = "In Debian we are currently applying the following "
             . "patch to $opt_dist.\n"
@@ -411,16 +410,18 @@ sub prepare_body {
         $body = wrap( '', '', $body );
         $body .= "\n\n";
 
-        open my $patch_fh, '<', $patch;
-
-        while ( my $line = <$patch_fh> ) {
-            chomp($line);
-            last if $line eq '---';
-            last if $line =~ /^--- /;
-            last if $line =~ /^diff\h--git\ha\//;
-            last if $line =~ /^index\h[0-9a-f]+\.\.[0-9a-f]+\h\d*\h/;
-            next if $line =~ /^Forwarded:/;
-            $body .= $pre . $line . "\n";
+        if ( $opt_tracker ne 'github' ) {
+            open my $patch_fh, '<', $patch;
+
+            while ( my $line = <$patch_fh> ) {
+                chomp($line);
+                last if $line eq '---';
+                last if $line =~ /^--- /;
+                last if $line =~ /^diff\h--git\ha\//;
+                last if $line =~ /^index\h[0-9a-f]+\.\.[0-9a-f]+\h\d*\h/;
+                next if $line =~ /^Forwarded:/;
+                $body .= $line . "\n";
+            }
         }
     }
     else {
@@ -607,23 +608,44 @@ sub submit_github {
         access_token => $ENV{DPT_GITHUB_OAUTH},
     );
 
-    $gh->set_default_user_repo( $gh_user, $gh_repo );
-
-    my $issue;
-    if ($opt_ticket) {
-        $issue = $gh->issue->issue($opt_ticket);
-        $gh->issue->create_comment( $opt_ticket, { body => $body } );
+    if ($patch) {
+        my $orgname = 'pkg-perl-tools';
+        die "Cannot find your GitHub user in $orgname organization"
+            unless $gh->user->show($orgname)->{login} eq $orgname;
+
+        create_fork($gh, $gh_user, $gh_repo, $orgname)
+            unless fork_exists($gh, $orgname, $gh_repo);
+
+        my $branch = "pkg-perl-$^T";
+        clone_branch_patch_push($orgname, $gh_repo, $branch, $patch, $subject);
+
+        $issue_url = create_pull_request($gh, $gh_user, $gh_repo, {
+            title  => $subject,
+            body   => $body,
+            head   => "$orgname:$branch",
+            base   => 'master',
+            labels => [ split( /,/, $gh_labels ) ],
+        });
     }
     else {
-        $issue = $gh->issue->create_issue(
-            {   title  => $subject,
-                body   => $body,
-                labels => [ split( /,/, $gh_labels ) ],
-            }
-        );
-    }
+        $gh->set_default_user_repo( $gh_user, $gh_repo );
 
-    $issue_url = $issue->{html_url};
+        my $issue;
+        if ($opt_ticket) {
+            $issue = $gh->issue->issue($opt_ticket);
+            $gh->issue->create_comment( $opt_ticket, { body => $body } );
+        }
+        else {
+            $issue = $gh->issue->create_issue(
+                {   title  => $subject,
+                    body   => $body,
+                    labels => [ split( /,/, $gh_labels ) ],
+                }
+            );
+        }
+
+        $issue_url = $issue->{html_url};
+    }
 
 ISSUE_CREATED:
     mark_patch_as_forwarded($issue_url) if $patch;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to