Skip to content

Commit 9ee0b00

Browse files
author
Leigh Hart
committed
added support for passing permission to add_team_repos
1 parent 415cfda commit 9ee0b00

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

examples/add_team_repos.pl

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
use FindBin qw/$Bin/;
6+
use lib "$Bin/../lib";
7+
use Net::GitHub::V3;
8+
use Data::Dumper;
9+
10+
die unless ( ($ENV{GITHUB_USER} and $ENV{GITHUB_PASS}) or $ENV{GITHUB_ACCESS_TOKEN} );
11+
12+
# either user+pass or token
13+
my $gh = Net::GitHub::V3->new( login => $ENV{GITHUB_USER}, pass => $ENV{GITHUB_PASS});
14+
# my $gh = Net::GitHub->new( access_token => $ENV{GITHUB_ACCESS_TOKEN});
15+
16+
my $x = $gh->repos->create({
17+
name => "Foo-Bar-Baz",
18+
org => "Yoink",
19+
});
20+
21+
$gh->org->add_team_repos($team_id, "Yoink/Foo-Bar-Baz", { permission => 'admin' })
22+
or die ("Could not add or update team on repository with permission admin");
23+
24+
1;

lib/Net/GitHub/V3/Orgs.pm

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ my %__methods = (
4040
delete_team_member => { url => "/teams/%s/members/%s", method => 'DELETE', check_status => 204 },
4141
team_repos => { url => "/teams/%s/repos" },
4242
is_team_repos => { url => "/teams/%s/repos/%s", check_status => 204 },
43-
add_team_repos => { url => "/teams/%s/repos/%s", method => 'PUT', check_status => 204 },
43+
add_team_repos => { url => "/teams/%s/repos/%s", method => 'PUT', args => 1, check_status => 204 },
4444
delete_team_repos => { url => "/teams/%s/repos/%s", method => 'DELETE', check_status => 204 },
4545
);
4646
__build_methods(__PACKAGE__, %__methods);
@@ -167,6 +167,9 @@ L<http://developer.github.com/v3/orgs/teams/>
167167
my @repos = $org->team_repos($team_id);
168168
my $is_team_repos = $org->is_team_repos($team_id, 'Hello-World');
169169
my $st = $org->add_team_repos($team_id, 'Hello-World');
170+
my $st = $org->add_team_repos($team_id, 'YoinkOrg/Hello-World', { permission => 'admin' });
171+
my $st = $org->add_team_repos($team_id, 'YoinkOrg/Hello-World', { permission => 'push' });
172+
my $st = $org->add_team_repos($team_id, 'YoinkOrg/Hello-World', { permission => 'pull' });
170173
my $st = $org->delete_team_repos($team_id, 'Hello-World');
171174
172175
=back

0 commit comments

Comments
 (0)