---
name: "Debian::PkgPerl::GitHub"
section: "3pm"
platform: "linux"
package: "pkg-perl-tools"
version: "0.82"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Debian::PkgPerl::GitHub"
---

# Debian::PkgPerl::GitHub(3pm)

Help forwarding a bug or a patch to GitHub

## NAME

Debian::PkgPerl::GitHub - Help forwarding a bug or a patch to GitHub

## SYNOPSIS

```
    use Debian::PkgPerl::Bug;
    use Debian::PkgPerl::Patch;
    use Debian::PkgPerl::Message;
    use Debian::PkgPerl::GitHub;

    my %params = (
        url     => 'https://github.com/foo/bar/issues',
        tracker => 'github',
        dist    => 'Foo-Bar',
        name    => 'My Name',
        email   => 'my.name@example.com',
        mailto  => 'your.name@example.com',
    );

    my %bug_info = Debian::PkgPerl::Bug
        ->new( bug => 123 )
        ->retrieve_bug_info();
    my $bug_msg = Debian::PkgPerl::Message->new(
        %params,
        info => \%bug_info,
    );
    print Debian::PkgPerl::GitHub->new(
        message => $bug_msg,
        ticket  => 456,
    )->forward();

    my %patch_info = Debian::PkgPerl::Patch
        ->new( patch => 'foo-bar.patch' )
        ->retrieve_patch_info();
    my $patch_msg = Debian::PkgPerl::Message->new(
        %params,
        info => \%patch_info,
    );
    print Debian::PkgPerl::GitHub->new(
        message  => $patch_msg,
        fallback => 0,
    )->forward();
```

## DESCRIPTION

This module exports several helpers that that provide support for forwarding patches to GitHub as pull requests.

## METHODS

### new(%params)

*Parameters:*

- •

  message

  Message to be forwarded to an upstream project.

- •

  ticket

  Existing issue number to forward the bug to.

- •

  fallback

  Enables fallback to forwarding a patch as an issue if pull-request fails for any reason. Default is false.

*Environment:*

- •

  DPT\_GITHUB\_OAUTH

  GitHub personal API token. No default.

- •

  DPT\_GITHUB\_ORGNAME

  Organization used to fork upstreams. Defaults to *pkg-perl-tools*.

- •

  DPT\_GITHUB\_BRANCH

  Branch name for pull requests. Defaults to `"pkg-perl-$^T"`.

- •

  DPT\_GITHUB\_PROTOCOL

  Protocol used to clone a repository. Defaults to *ssh*. Accepted protocols: *ssh*, *https*.

### fork\_exists()

Checks if any member in the GitHub organization has already forked a repository.

*Returns:*

Boolean value.

### create\_fork()

Creates a repository fork by an organization.

*Returns:*

The new forked repository.

### clone\_branch\_patch\_push()

Clones a repository in a temporary directory, creates a new branch, applies the patch, commits the change, pushes it and removes the temporary working copy.

*Returns:*

Nothing.

### create\_pull\_request()

*Returns:*

Pull request URL on success, nothing otherwise.

### forward\_patch\_as\_pull\_request()

### forward\_patch\_as\_ticket()

Fallback to forwarding a patch as a bug.

*Returns:*

Issue URL on success, nothing otherwise.

### forward\_bug\_as\_issue()

### forward()

Forward an issue as a pull request or bug.

### test()

Support for off-line testing.

## LICENSE AND COPYRIGHT

- Copyright 2016 Alex Muntada.

  - Copyright 2018 Damyan Ivanov.

  This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.
