App-BitBucketCli

 view release on metacpan or  search on metacpan

lib/App/BitBucketCli/Command/PullRequests.pm  view on Meta::CPAN

package App::BitBucketCli::Command::PullRequests;

# Created on: 2018-06-07 08:23:20
# Create by:  Ivan Wills
# $Id$
# $Revision$, $HeadURL$, $Date$
# $Revision$, $Source$, $Date$

use Moo;
use warnings;
use Carp;
use Data::Dumper qw/Dumper/;
use English qw/ -no_match_vars /;
use Path::Tiny;

extends 'App::BitBucketCli';

our $VERSION = 0.009;

sub options {
    return [qw/
        colors|c=s%
        create|C
        force|f!
        author|a=s
        emails|e=s
        to_branch|to-branch|t=s
        from_branch|from-branch|f=s
        title|T=s
        state|S=s
        long|l
        project|p=s
        participant|P=s
        regexp|R
        remote|m=s
        repository|r=s
        sleep|s=i
    /]
}

sub pull_requests {
    my ($self) = @_;

    my $author      = $self->opt->author();
    my $to_branch   = $self->opt->to_branch();
    my $from_branch = $self->opt->from_branch();
    my $title       = $self->opt->title();
    my $emails      = $self->opt->emails();
    my $participant = $self->opt->participant();

    if ( $self->opt->create() ) {
        #https://stash.ext.springdigital-devisland.com.au/projects/SD/repos/onlinestyleguide/pull-requests
        #    ?create
        #    &targetBranch=refs%2Fheads%2Fproject_shop_performance
        #    &sourceBranch=refs%2Fheads%2Fbugfix%2FALM-48995_hidden-scroll-bar3
        #    &targetRepoId=12
        if ( ! $self->opt->{from_branch} ) {
            my $dir = `git rev-parse --show-toplevel`;
            chomp $dir;
            my $head = path($dir, '.git', 'HEAD');

            if ( -s $head ) {
                $head = $head->slurp;
                chomp $head;
                $head =~ s{^ref: refs/heads/}{};
                $self->opt->{from_branch} = $head;
            }
        }

        my $url = $self->core->url;
        $url =~ s{^(https?://)([^/]+?@)}{$1};
        $url =~ s{/rest/.*}{};



( run in 0.679 second using v1.01-cache-2.11-cpan-39bf76dae61 )