7 # OpenSSL project number
24 $state = "$1" if (/^--state=(.*)$/);
25 $desc = "$1" if (/^--desc=(.*)$/);
26 $token = "$1" if (/^--token=(.*)$/);
27 $user = "$1" if (/^--user=(.*)$/);
28 $num = $_ if (/^\d+$/);
29 $text = 1 if (/^--text$/);
30 $fetch = 1 if (/^--fetch$/);
31 $fetch = 2 if (/^--checkout$/);
34 if ( !defined $token && -f "$ENV{HOME}/.gitlabtoken" ) {
35 open( IN, "$ENV{HOME}/.gitlabtoken" );
41 if ( !defined $token ) {
42 print STDERR "Gitlab token not defined!\n";
47 # Page number for gitlab query
51 my $response = HTTP::Tiny->new->get(
52 "https://gitlab.openssl.org/api/v3/projects/$proj/merge_requests/?state=$state;per_page=100;page=$pnum;private_token=$token"
54 if ( !$response->{success} ) {
55 print "Failed: $response->{status}, $response->{reason}\n";
58 my $resp = decode_json $response->{content};
62 next if ( defined $num && $_->{iid} ne $num );
63 next if ( defined $desc && $_->{description} !~ /$desc/ );
64 next if ( defined $user && $_->{author}->{username} ne $user );
70 if ( @matches == 0 ) {
71 print "ERROR: no matching requests found\n";
74 if ( $fetch && @matches != 1 ) {
75 print "ERROR: multiple matching requests\n";
80 print_req( $_, $text );
82 my $br = $_->{source_branch};
83 my $user = $_->{author}->{username};
85 "git fetch git\@gitlab.openssl.org:$user/openssl.git $br:$br"
87 system("git checkout $br") if $fetch == 2;
92 my ( $req, $all ) = @_;
94 print "Merge request: $req->{iid}, author: $req->{author}->{username},";
95 print " state: $req->{state}\n";
97 #print " branch: $req->{source_branch}\n";
98 print " Title: $req->{title}\n";
100 print "Description:\n";
102 # Note: using tabs here causes a failure
103 print fill( " ", " ", $req->{description} ) . "\n";