Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
39735939
Commit
39735939
authored
Aug 03, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update go-github dependency.
parent
2e68002f
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
429 additions
and
85 deletions
+429
-85
Godeps.json
Godeps/Godeps.json
+1
-1
activity_star.go
...e/src/github.com/google/go-github/github/activity_star.go
+11
-2
activity_star_test.go
.../github.com/google/go-github/github/activity_star_test.go
+7
-4
doc.go
.../_workspace/src/github.com/google/go-github/github/doc.go
+2
-13
gists.go
...workspace/src/github.com/google/go-github/github/gists.go
+1
-1
github.go
...orkspace/src/github.com/google/go-github/github/github.go
+8
-1
issues.go
...orkspace/src/github.com/google/go-github/github/issues.go
+2
-2
issues_events.go
...e/src/github.com/google/go-github/github/issues_events.go
+6
-0
licenses.go
...kspace/src/github.com/google/go-github/github/licenses.go
+2
-2
licenses_test.go
...e/src/github.com/google/go-github/github/licenses_test.go
+1
-1
misc.go
..._workspace/src/github.com/google/go-github/github/misc.go
+4
-0
misc_test.go
...space/src/github.com/google/go-github/github/misc_test.go
+2
-1
orgs_members.go
...ce/src/github.com/google/go-github/github/orgs_members.go
+63
-10
orgs_members_test.go
...c/github.com/google/go-github/github/orgs_members_test.go
+71
-4
orgs_teams.go
...pace/src/github.com/google/go-github/github/orgs_teams.go
+95
-16
orgs_teams_test.go
...src/github.com/google/go-github/github/orgs_teams_test.go
+52
-20
pulls_comments.go
.../src/github.com/google/go-github/github/pulls_comments.go
+1
-1
repos_collaborators.go
...github.com/google/go-github/github/repos_collaborators.go
+22
-2
repos_collaborators_test.go
...b.com/google/go-github/github/repos_collaborators_test.go
+14
-2
repos_releases.go
.../src/github.com/google/go-github/github/repos_releases.go
+20
-1
repos_releases_test.go
...github.com/google/go-github/github/repos_releases_test.go
+40
-0
repos_test.go
...pace/src/github.com/google/go-github/github/repos_test.go
+0
-1
users.go
...workspace/src/github.com/google/go-github/github/users.go
+4
-0
No files found.
Godeps/Godeps.json
View file @
39735939
...
@@ -340,7 +340,7 @@
...
@@ -340,7 +340,7 @@
},
},
{
{
"ImportPath"
:
"github.com/google/go-github/github"
,
"ImportPath"
:
"github.com/google/go-github/github"
,
"Rev"
:
"
930e6fdb8dc2b11458fdeb55b3cd68e5370a1a2
8"
"Rev"
:
"
800345634beceb9b499012319eb8bf97fd97a29
8"
},
},
{
{
"ImportPath"
:
"github.com/google/go-querystring/query"
,
"ImportPath"
:
"github.com/google/go-querystring/query"
,
...
...
Godeps/_workspace/src/github.com/google/go-github/github/activity_star.go
View file @
39735939
...
@@ -7,6 +7,12 @@ package github
...
@@ -7,6 +7,12 @@ package github
import
"fmt"
import
"fmt"
// StarredRepository is returned by ListStarred.
type
StarredRepository
struct
{
StarredAt
*
Timestamp
`json:"starred_at,omitempty"`
Repository
*
Repository
`json:"repo,omitempty"`
}
// ListStargazers lists people who have starred the specified repo.
// ListStargazers lists people who have starred the specified repo.
//
//
// GitHub API Docs: https://developer.github.com/v3/activity/starring/#list-stargazers
// GitHub API Docs: https://developer.github.com/v3/activity/starring/#list-stargazers
...
@@ -49,7 +55,7 @@ type ActivityListStarredOptions struct {
...
@@ -49,7 +55,7 @@ type ActivityListStarredOptions struct {
// will list the starred repositories for the authenticated user.
// will list the starred repositories for the authenticated user.
//
//
// GitHub API docs: http://developer.github.com/v3/activity/starring/#list-repositories-being-starred
// GitHub API docs: http://developer.github.com/v3/activity/starring/#list-repositories-being-starred
func
(
s
*
ActivityService
)
ListStarred
(
user
string
,
opt
*
ActivityListStarredOptions
)
([]
Repository
,
*
Response
,
error
)
{
func
(
s
*
ActivityService
)
ListStarred
(
user
string
,
opt
*
ActivityListStarredOptions
)
([]
Starred
Repository
,
*
Response
,
error
)
{
var
u
string
var
u
string
if
user
!=
""
{
if
user
!=
""
{
u
=
fmt
.
Sprintf
(
"users/%v/starred"
,
user
)
u
=
fmt
.
Sprintf
(
"users/%v/starred"
,
user
)
...
@@ -66,7 +72,10 @@ func (s *ActivityService) ListStarred(user string, opt *ActivityListStarredOptio
...
@@ -66,7 +72,10 @@ func (s *ActivityService) ListStarred(user string, opt *ActivityListStarredOptio
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
repos
:=
new
([]
Repository
)
// TODO: remove custom Accept header when this API fully launches
req
.
Header
.
Set
(
"Accept"
,
mediaTypeStarringPreview
)
repos
:=
new
([]
StarredRepository
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
repos
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
repos
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
resp
,
err
return
nil
,
resp
,
err
...
...
Godeps/_workspace/src/github.com/google/go-github/github/activity_star_test.go
View file @
39735939
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"net/http"
"net/http"
"reflect"
"reflect"
"testing"
"testing"
"time"
)
)
func
TestActivityService_ListStargazers
(
t
*
testing
.
T
)
{
func
TestActivityService_ListStargazers
(
t
*
testing
.
T
)
{
...
@@ -42,7 +43,8 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) {
...
@@ -42,7 +43,8 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) {
mux
.
HandleFunc
(
"/user/starred"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/user/starred"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprint
(
w
,
`[{"id":1}]`
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeStarringPreview
)
fmt
.
Fprint
(
w
,
`[{"starred_at":"2002-02-10T15:30:00Z","repo":{"id":1}}]`
)
})
})
repos
,
_
,
err
:=
client
.
Activity
.
ListStarred
(
""
,
nil
)
repos
,
_
,
err
:=
client
.
Activity
.
ListStarred
(
""
,
nil
)
...
@@ -50,7 +52,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) {
...
@@ -50,7 +52,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) {
t
.
Errorf
(
"Activity.ListStarred returned error: %v"
,
err
)
t
.
Errorf
(
"Activity.ListStarred returned error: %v"
,
err
)
}
}
want
:=
[]
Repository
{{
ID
:
Int
(
1
)
}}
want
:=
[]
StarredRepository
{{
StarredAt
:
&
Timestamp
{
time
.
Date
(
2002
,
time
.
February
,
10
,
15
,
30
,
0
,
0
,
time
.
UTC
)},
Repository
:
&
Repository
{
ID
:
Int
(
1
)}
}}
if
!
reflect
.
DeepEqual
(
repos
,
want
)
{
if
!
reflect
.
DeepEqual
(
repos
,
want
)
{
t
.
Errorf
(
"Activity.ListStarred returned %+v, want %+v"
,
repos
,
want
)
t
.
Errorf
(
"Activity.ListStarred returned %+v, want %+v"
,
repos
,
want
)
}
}
...
@@ -62,12 +64,13 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) {
...
@@ -62,12 +64,13 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) {
mux
.
HandleFunc
(
"/users/u/starred"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/users/u/starred"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
testMethod
(
t
,
r
,
"GET"
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeStarringPreview
)
testFormValues
(
t
,
r
,
values
{
testFormValues
(
t
,
r
,
values
{
"sort"
:
"created"
,
"sort"
:
"created"
,
"direction"
:
"asc"
,
"direction"
:
"asc"
,
"page"
:
"2"
,
"page"
:
"2"
,
})
})
fmt
.
Fprint
(
w
,
`[{"
id":2
}]`
)
fmt
.
Fprint
(
w
,
`[{"
starred_at":"2002-02-10T15:30:00Z","repo":{"id":2}
}]`
)
})
})
opt
:=
&
ActivityListStarredOptions
{
"created"
,
"asc"
,
ListOptions
{
Page
:
2
}}
opt
:=
&
ActivityListStarredOptions
{
"created"
,
"asc"
,
ListOptions
{
Page
:
2
}}
...
@@ -76,7 +79,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) {
...
@@ -76,7 +79,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) {
t
.
Errorf
(
"Activity.ListStarred returned error: %v"
,
err
)
t
.
Errorf
(
"Activity.ListStarred returned error: %v"
,
err
)
}
}
want
:=
[]
Repository
{{
ID
:
Int
(
2
)
}}
want
:=
[]
StarredRepository
{{
StarredAt
:
&
Timestamp
{
time
.
Date
(
2002
,
time
.
February
,
10
,
15
,
30
,
0
,
0
,
time
.
UTC
)},
Repository
:
&
Repository
{
ID
:
Int
(
2
)}
}}
if
!
reflect
.
DeepEqual
(
repos
,
want
)
{
if
!
reflect
.
DeepEqual
(
repos
,
want
)
{
t
.
Errorf
(
"Activity.ListStarred returned %+v, want %+v"
,
repos
,
want
)
t
.
Errorf
(
"Activity.ListStarred returned %+v, want %+v"
,
repos
,
want
)
}
}
...
...
Godeps/_workspace/src/github.com/google/go-github/github/doc.go
View file @
39735939
...
@@ -35,21 +35,10 @@ use it with the oauth2 library using:
...
@@ -35,21 +35,10 @@ use it with the oauth2 library using:
import "golang.org/x/oauth2"
import "golang.org/x/oauth2"
// tokenSource is an oauth2.TokenSource which returns a static access token
type tokenSource struct {
token *oauth2.Token
}
// Token implements the oauth2.TokenSource interface
func (t *tokenSource) Token() (*oauth2.Token, error){
return t.token, nil
}
func main() {
func main() {
ts :=
&tokenSource{
ts :=
oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: "... your access token ..."},
&oauth2.Token{AccessToken: "... your access token ..."},
}
)
tc := oauth2.NewClient(oauth2.NoContext, ts)
tc := oauth2.NewClient(oauth2.NoContext, ts)
client := github.NewClient(tc)
client := github.NewClient(tc)
...
...
Godeps/_workspace/src/github.com/google/go-github/github/gists.go
View file @
39735939
...
@@ -157,7 +157,7 @@ func (s *GistsService) Get(id string) (*Gist, *Response, error) {
...
@@ -157,7 +157,7 @@ func (s *GistsService) Get(id string) (*Gist, *Response, error) {
return
gist
,
resp
,
err
return
gist
,
resp
,
err
}
}
// Get a specific revision of a gist.
// Get
Revision gets
a specific revision of a gist.
//
//
// GitHub API docs: https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
// GitHub API docs: https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
func
(
s
*
GistsService
)
GetRevision
(
id
,
sha
string
)
(
*
Gist
,
*
Response
,
error
)
{
func
(
s
*
GistsService
)
GetRevision
(
id
,
sha
string
)
(
*
Gist
,
*
Response
,
error
)
{
...
...
Godeps/_workspace/src/github.com/google/go-github/github/github.go
View file @
39735939
...
@@ -39,6 +39,13 @@ const (
...
@@ -39,6 +39,13 @@ const (
// https://developer.github.com/changes/2015-03-09-licenses-api/
// https://developer.github.com/changes/2015-03-09-licenses-api/
mediaTypeLicensesPreview
=
"application/vnd.github.drax-preview+json"
mediaTypeLicensesPreview
=
"application/vnd.github.drax-preview+json"
// https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/
mediaTypeStarringPreview
=
"application/vnd.github.v3.star+json"
// https://developer.github.com/changes/2015-06-24-api-enhancements-for-working-with-organization-permissions/
mediaTypeOrgPermissionPreview
=
"application/vnd.github.ironman-preview+json"
mediaTypeOrgPermissionRepoPreview
=
"application/vnd.github.ironman-preview.repository+json"
)
)
// A Client manages communication with the GitHub API.
// A Client manages communication with the GitHub API.
...
@@ -218,7 +225,7 @@ type Response struct {
...
@@ -218,7 +225,7 @@ type Response struct {
Rate
Rate
}
}
// newResponse creats a new Response for the provided http.Response.
// newResponse creat
e
s a new Response for the provided http.Response.
func
newResponse
(
r
*
http
.
Response
)
*
Response
{
func
newResponse
(
r
*
http
.
Response
)
*
Response
{
response
:=
&
Response
{
Response
:
r
}
response
:=
&
Response
{
Response
:
r
}
response
.
populatePageValues
()
response
.
populatePageValues
()
...
...
Godeps/_workspace/src/github.com/google/go-github/github/issues.go
View file @
39735939
...
@@ -72,7 +72,7 @@ type IssueListOptions struct {
...
@@ -72,7 +72,7 @@ type IssueListOptions struct {
Labels
[]
string
`url:"labels,comma,omitempty"`
Labels
[]
string
`url:"labels,comma,omitempty"`
// Sort specifies how to sort issues. Possible values are: created, updated,
// Sort specifies how to sort issues. Possible values are: created, updated,
// and comments. Default value is "
assign
ed".
// and comments. Default value is "
creat
ed".
Sort
string
`url:"sort,omitempty"`
Sort
string
`url:"sort,omitempty"`
// Direction in which to sort issues. Possible values are: asc, desc.
// Direction in which to sort issues. Possible values are: asc, desc.
...
@@ -166,7 +166,7 @@ type IssueListByRepoOptions struct {
...
@@ -166,7 +166,7 @@ type IssueListByRepoOptions struct {
Labels
[]
string
`url:"labels,omitempty,comma"`
Labels
[]
string
`url:"labels,omitempty,comma"`
// Sort specifies how to sort issues. Possible values are: created, updated,
// Sort specifies how to sort issues. Possible values are: created, updated,
// and comments. Default value is "
assign
ed".
// and comments. Default value is "
creat
ed".
Sort
string
`url:"sort,omitempty"`
Sort
string
`url:"sort,omitempty"`
// Direction in which to sort issues. Possible values are: asc, desc.
// Direction in which to sort issues. Possible values are: asc, desc.
...
...
Godeps/_workspace/src/github.com/google/go-github/github/issues_events.go
View file @
39735939
...
@@ -49,6 +49,9 @@ type IssueEvent struct {
...
@@ -49,6 +49,9 @@ type IssueEvent struct {
//
//
// head_ref_restored
// head_ref_restored
// The pull request’s branch was restored.
// The pull request’s branch was restored.
//
// labeled
// A label was added.
Event
*
string
`json:"event,omitempty"`
Event
*
string
`json:"event,omitempty"`
// The SHA of the commit that referenced this commit, if applicable.
// The SHA of the commit that referenced this commit, if applicable.
...
@@ -56,6 +59,9 @@ type IssueEvent struct {
...
@@ -56,6 +59,9 @@ type IssueEvent struct {
CreatedAt
*
time
.
Time
`json:"created_at,omitempty"`
CreatedAt
*
time
.
Time
`json:"created_at,omitempty"`
Issue
*
Issue
`json:"issue,omitempty"`
Issue
*
Issue
`json:"issue,omitempty"`
// Only present on 'labeled' events
Label
*
Label
`json:"label,omitempty"`
}
}
// ListIssueEvents lists events for the specified issue.
// ListIssueEvents lists events for the specified issue.
...
...
Godeps/_workspace/src/github.com/google/go-github/github/licenses.go
View file @
39735939
...
@@ -21,7 +21,7 @@ type License struct {
...
@@ -21,7 +21,7 @@ type License struct {
Name
*
string
`json:"name,omitempty"`
Name
*
string
`json:"name,omitempty"`
URL
*
string
`json:"url,omitempty"`
URL
*
string
`json:"url,omitempty"`
HTMLURL
*
string
`json:"html_url
",omitempty
`
HTMLURL
*
string
`json:"html_url
,omitempty"
`
Featured
*
bool
`json:"featured,omitempty"`
Featured
*
bool
`json:"featured,omitempty"`
Description
*
string
`json:"description,omitempty"`
Description
*
string
`json:"description,omitempty"`
Category
*
string
`json:"category,omitempty"`
Category
*
string
`json:"category,omitempty"`
...
@@ -57,7 +57,7 @@ func (s *LicensesService) List() ([]License, *Response, error) {
...
@@ -57,7 +57,7 @@ func (s *LicensesService) List() ([]License, *Response, error) {
return
*
licenses
,
resp
,
err
return
*
licenses
,
resp
,
err
}
}
//
Fetch
extended metadata for one license.
//
Get
extended metadata for one license.
//
//
// GitHub API docs: https://developer.github.com/v3/licenses/#get-an-individual-license
// GitHub API docs: https://developer.github.com/v3/licenses/#get-an-individual-license
func
(
s
*
LicensesService
)
Get
(
licenseName
string
)
(
*
License
,
*
Response
,
error
)
{
func
(
s
*
LicensesService
)
Get
(
licenseName
string
)
(
*
License
,
*
Response
,
error
)
{
...
...
Godeps/_workspace/src/github.com/google/go-github/github/licenses_test.go
View file @
39735939
...
@@ -27,7 +27,7 @@ func TestLicensesService_List(t *testing.T) {
...
@@ -27,7 +27,7 @@ func TestLicensesService_List(t *testing.T) {
t
.
Errorf
(
"Licenses.List returned error: %v"
,
err
)
t
.
Errorf
(
"Licenses.List returned error: %v"
,
err
)
}
}
want
:=
[]
License
{
License
{
want
:=
[]
License
{{
Key
:
String
(
"mit"
),
Key
:
String
(
"mit"
),
Name
:
String
(
"MIT"
),
Name
:
String
(
"MIT"
),
URL
:
String
(
"https://api.github.com/licenses/mit"
),
URL
:
String
(
"https://api.github.com/licenses/mit"
),
...
...
Godeps/_workspace/src/github.com/google/go-github/github/misc.go
View file @
39735939
...
@@ -98,6 +98,10 @@ type APIMeta struct {
...
@@ -98,6 +98,10 @@ type APIMeta struct {
// username and password, sudo mode, and two-factor authentication are
// username and password, sudo mode, and two-factor authentication are
// not supported on these servers.)
// not supported on these servers.)
VerifiablePasswordAuthentication
*
bool
`json:"verifiable_password_authentication,omitempty"`
VerifiablePasswordAuthentication
*
bool
`json:"verifiable_password_authentication,omitempty"`
// An array of IP addresses in CIDR format specifying the addresses
// which serve GitHub Pages websites.
Pages
[]
string
`json:"pages,omitempty"`
}
}
// APIMeta returns information about GitHub.com, the service. Or, if you access
// APIMeta returns information about GitHub.com, the service. Or, if you access
...
...
Godeps/_workspace/src/github.com/google/go-github/github/misc_test.go
View file @
39735939
...
@@ -72,7 +72,7 @@ func TestAPIMeta(t *testing.T) {
...
@@ -72,7 +72,7 @@ func TestAPIMeta(t *testing.T) {
mux
.
HandleFunc
(
"/meta"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/meta"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprint
(
w
,
`{"hooks":["h"], "git":["g"], "verifiable_password_authentication": true}`
)
fmt
.
Fprint
(
w
,
`{"hooks":["h"], "git":["g"], "
pages":["p"], "
verifiable_password_authentication": true}`
)
})
})
meta
,
_
,
err
:=
client
.
APIMeta
()
meta
,
_
,
err
:=
client
.
APIMeta
()
...
@@ -83,6 +83,7 @@ func TestAPIMeta(t *testing.T) {
...
@@ -83,6 +83,7 @@ func TestAPIMeta(t *testing.T) {
want
:=
&
APIMeta
{
want
:=
&
APIMeta
{
Hooks
:
[]
string
{
"h"
},
Hooks
:
[]
string
{
"h"
},
Git
:
[]
string
{
"g"
},
Git
:
[]
string
{
"g"
},
Pages
:
[]
string
{
"p"
},
VerifiablePasswordAuthentication
:
Bool
(
true
),
VerifiablePasswordAuthentication
:
Bool
(
true
),
}
}
if
!
reflect
.
DeepEqual
(
want
,
meta
)
{
if
!
reflect
.
DeepEqual
(
want
,
meta
)
{
...
...
Godeps/_workspace/src/github.com/google/go-github/github/orgs_members.go
View file @
39735939
...
@@ -15,7 +15,16 @@ type Membership struct {
...
@@ -15,7 +15,16 @@ type Membership struct {
// Possible values are: "active", "pending"
// Possible values are: "active", "pending"
State
*
string
`json:"state,omitempty"`
State
*
string
`json:"state,omitempty"`
// TODO(willnorris): add docs
// Role identifies the user's role within the organization or team.
// Possible values for organization membership:
// member - non-owner organization member
// admin - organization owner
//
// Possible values for team membership are:
// member - a normal member of the team
// maintainer - a team maintainer. Able to add/remove other team
// members, promote other team members to team
// maintainer, and edit the team’s name and description
Role
*
string
`json:"role,omitempty"`
Role
*
string
`json:"role,omitempty"`
// For organization membership, the API URL of the organization.
// For organization membership, the API URL of the organization.
...
@@ -43,6 +52,15 @@ type ListMembersOptions struct {
...
@@ -43,6 +52,15 @@ type ListMembersOptions struct {
// 2fa_disabled, all. Default is "all".
// 2fa_disabled, all. Default is "all".
Filter
string
`url:"filter,omitempty"`
Filter
string
`url:"filter,omitempty"`
// Role filters memebers returned by their role in the organization.
// Possible values are:
// all - all members of the organization, regardless of role
// admin - organization owners
// member - non-organization members
//
// Default is "all".
Role
string
`url:"role,omitempty"`
ListOptions
ListOptions
}
}
...
@@ -68,6 +86,10 @@ func (s *OrganizationsService) ListMembers(org string, opt *ListMembersOptions)
...
@@ -68,6 +86,10 @@ func (s *OrganizationsService) ListMembers(org string, opt *ListMembersOptions)
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
if
opt
!=
nil
&&
opt
.
Role
!=
""
{
req
.
Header
.
Set
(
"Accept"
,
mediaTypeOrgPermissionPreview
)
}
members
:=
new
([]
User
)
members
:=
new
([]
User
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
members
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
members
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -120,7 +142,8 @@ func (s *OrganizationsService) RemoveMember(org, user string) (*Response, error)
...
@@ -120,7 +142,8 @@ func (s *OrganizationsService) RemoveMember(org, user string) (*Response, error)
return
s
.
client
.
Do
(
req
,
nil
)
return
s
.
client
.
Do
(
req
,
nil
)
}
}
// PublicizeMembership publicizes a user's membership in an organization.
// PublicizeMembership publicizes a user's membership in an organization. (A
// user cannot publicize the membership for another user.)
//
//
// GitHub API docs: http://developer.github.com/v3/orgs/members/#publicize-a-users-membership
// GitHub API docs: http://developer.github.com/v3/orgs/members/#publicize-a-users-membership
func
(
s
*
OrganizationsService
)
PublicizeMembership
(
org
,
user
string
)
(
*
Response
,
error
)
{
func
(
s
*
OrganizationsService
)
PublicizeMembership
(
org
,
user
string
)
(
*
Response
,
error
)
{
...
@@ -180,12 +203,20 @@ func (s *OrganizationsService) ListOrgMemberships(opt *ListOrgMembershipsOptions
...
@@ -180,12 +203,20 @@ func (s *OrganizationsService) ListOrgMemberships(opt *ListOrgMembershipsOptions
return
memberships
,
resp
,
err
return
memberships
,
resp
,
err
}
}
// GetOrgMembership gets the membership for the authenticated user for the
// GetOrgMembership gets the membership for a user in a specified organization.
// specified organization.
// Passing an empty string for user will get the membership for the
// authenticated user.
//
//
// GitHub API docs: https://developer.github.com/v3/orgs/members/#get-organization-membership
// GitHub API docs: https://developer.github.com/v3/orgs/members/#get-your-organization-membership
// GitHub API docs: https://developer.github.com/v3/orgs/members/#get-your-organization-membership
func
(
s
*
OrganizationsService
)
GetOrgMembership
(
org
string
)
(
*
Membership
,
*
Response
,
error
)
{
func
(
s
*
OrganizationsService
)
GetOrgMembership
(
user
,
org
string
)
(
*
Membership
,
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"user/memberships/orgs/%v"
,
org
)
var
u
string
if
user
!=
""
{
u
=
fmt
.
Sprintf
(
"orgs/%v/memberships/%v"
,
org
,
user
)
}
else
{
u
=
fmt
.
Sprintf
(
"user/memberships/orgs/%v"
,
org
)
}
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
...
@@ -200,12 +231,20 @@ func (s *OrganizationsService) GetOrgMembership(org string) (*Membership, *Respo
...
@@ -200,12 +231,20 @@ func (s *OrganizationsService) GetOrgMembership(org string) (*Membership, *Respo
return
membership
,
resp
,
err
return
membership
,
resp
,
err
}
}
// EditOrgMembership edits the membership for the authenticated user for the
// EditOrgMembership edits the membership for user in specified organization.
// specified organization.
// Passing an empty string for user will edit the membership for the
// authenticated user.
//
//
// GitHub API docs: https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership
// GitHub API docs: https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
// GitHub API docs: https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
func
(
s
*
OrganizationsService
)
EditOrgMembership
(
org
string
,
membership
*
Membership
)
(
*
Membership
,
*
Response
,
error
)
{
func
(
s
*
OrganizationsService
)
EditOrgMembership
(
user
,
org
string
,
membership
*
Membership
)
(
*
Membership
,
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"user/memberships/orgs/%v"
,
org
)
var
u
string
if
user
!=
""
{
u
=
fmt
.
Sprintf
(
"orgs/%v/memberships/%v"
,
org
,
user
)
}
else
{
u
=
fmt
.
Sprintf
(
"user/memberships/orgs/%v"
,
org
)
}
req
,
err
:=
s
.
client
.
NewRequest
(
"PATCH"
,
u
,
membership
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PATCH"
,
u
,
membership
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
...
@@ -219,3 +258,17 @@ func (s *OrganizationsService) EditOrgMembership(org string, membership *Members
...
@@ -219,3 +258,17 @@ func (s *OrganizationsService) EditOrgMembership(org string, membership *Members
return
m
,
resp
,
err
return
m
,
resp
,
err
}
}
// RemoveOrgMembership removes user from the specified organization. If the
// user has been invited to the organization, this will cancel their invitation.
//
// GitHub API docs: https://developer.github.com/v3/orgs/members/#remove-organization-membership
func
(
s
*
OrganizationsService
)
RemoveOrgMembership
(
user
,
org
string
)
(
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"orgs/%v/memberships/%v"
,
org
,
user
)
req
,
err
:=
s
.
client
.
NewRequest
(
"DELETE"
,
u
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
return
s
.
client
.
Do
(
req
,
nil
)
}
Godeps/_workspace/src/github.com/google/go-github/github/orgs_members_test.go
View file @
39735939
...
@@ -19,8 +19,10 @@ func TestOrganizationsService_ListMembers(t *testing.T) {
...
@@ -19,8 +19,10 @@ func TestOrganizationsService_ListMembers(t *testing.T) {
mux
.
HandleFunc
(
"/orgs/o/members"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/orgs/o/members"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
testMethod
(
t
,
r
,
"GET"
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeOrgPermissionPreview
)
testFormValues
(
t
,
r
,
values
{
testFormValues
(
t
,
r
,
values
{
"filter"
:
"2fa_disabled"
,
"filter"
:
"2fa_disabled"
,
"role"
:
"admin"
,
"page"
:
"2"
,
"page"
:
"2"
,
})
})
fmt
.
Fprint
(
w
,
`[{"id":1}]`
)
fmt
.
Fprint
(
w
,
`[{"id":1}]`
)
...
@@ -29,6 +31,7 @@ func TestOrganizationsService_ListMembers(t *testing.T) {
...
@@ -29,6 +31,7 @@ func TestOrganizationsService_ListMembers(t *testing.T) {
opt
:=
&
ListMembersOptions
{
opt
:=
&
ListMembersOptions
{
PublicOnly
:
false
,
PublicOnly
:
false
,
Filter
:
"2fa_disabled"
,
Filter
:
"2fa_disabled"
,
Role
:
"admin"
,
ListOptions
:
ListOptions
{
Page
:
2
},
ListOptions
:
ListOptions
{
Page
:
2
},
}
}
members
,
_
,
err
:=
client
.
Organizations
.
ListMembers
(
"o"
,
opt
)
members
,
_
,
err
:=
client
.
Organizations
.
ListMembers
(
"o"
,
opt
)
...
@@ -239,7 +242,7 @@ func TestOrganizationsService_ListOrgMemberships(t *testing.T) {
...
@@ -239,7 +242,7 @@ func TestOrganizationsService_ListOrgMemberships(t *testing.T) {
}
}
}
}
func
TestOrganizationsService_GetOrgMembership
(
t
*
testing
.
T
)
{
func
TestOrganizationsService_GetOrgMembership
_AuthenticatedUser
(
t
*
testing
.
T
)
{
setup
()
setup
()
defer
teardown
()
defer
teardown
()
...
@@ -248,7 +251,7 @@ func TestOrganizationsService_GetOrgMembership(t *testing.T) {
...
@@ -248,7 +251,7 @@ func TestOrganizationsService_GetOrgMembership(t *testing.T) {
fmt
.
Fprint
(
w
,
`{"url":"u"}`
)
fmt
.
Fprint
(
w
,
`{"url":"u"}`
)
})
})
membership
,
_
,
err
:=
client
.
Organizations
.
GetOrgMembership
(
"o"
)
membership
,
_
,
err
:=
client
.
Organizations
.
GetOrgMembership
(
"
"
,
"
o"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Organizations.GetOrgMembership returned error: %v"
,
err
)
t
.
Errorf
(
"Organizations.GetOrgMembership returned error: %v"
,
err
)
}
}
...
@@ -259,7 +262,27 @@ func TestOrganizationsService_GetOrgMembership(t *testing.T) {
...
@@ -259,7 +262,27 @@ func TestOrganizationsService_GetOrgMembership(t *testing.T) {
}
}
}
}
func
TestOrganizationsService_EditOrgMembership
(
t
*
testing
.
T
)
{
func
TestOrganizationsService_GetOrgMembership_SpecifiedUser
(
t
*
testing
.
T
)
{
setup
()
defer
teardown
()
mux
.
HandleFunc
(
"/orgs/o/memberships/u"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprint
(
w
,
`{"url":"u"}`
)
})
membership
,
_
,
err
:=
client
.
Organizations
.
GetOrgMembership
(
"u"
,
"o"
)
if
err
!=
nil
{
t
.
Errorf
(
"Organizations.GetOrgMembership returned error: %v"
,
err
)
}
want
:=
&
Membership
{
URL
:
String
(
"u"
)}
if
!
reflect
.
DeepEqual
(
membership
,
want
)
{
t
.
Errorf
(
"Organizations.GetOrgMembership returned %+v, want %+v"
,
membership
,
want
)
}
}
func
TestOrganizationsService_EditOrgMembership_AuthenticatedUser
(
t
*
testing
.
T
)
{
setup
()
setup
()
defer
teardown
()
defer
teardown
()
...
@@ -277,7 +300,36 @@ func TestOrganizationsService_EditOrgMembership(t *testing.T) {
...
@@ -277,7 +300,36 @@ func TestOrganizationsService_EditOrgMembership(t *testing.T) {
fmt
.
Fprint
(
w
,
`{"url":"u"}`
)
fmt
.
Fprint
(
w
,
`{"url":"u"}`
)
})
})
membership
,
_
,
err
:=
client
.
Organizations
.
EditOrgMembership
(
"o"
,
input
)
membership
,
_
,
err
:=
client
.
Organizations
.
EditOrgMembership
(
""
,
"o"
,
input
)
if
err
!=
nil
{
t
.
Errorf
(
"Organizations.EditOrgMembership returned error: %v"
,
err
)
}
want
:=
&
Membership
{
URL
:
String
(
"u"
)}
if
!
reflect
.
DeepEqual
(
membership
,
want
)
{
t
.
Errorf
(
"Organizations.EditOrgMembership returned %+v, want %+v"
,
membership
,
want
)
}
}
func
TestOrganizationsService_EditOrgMembership_SpecifiedUser
(
t
*
testing
.
T
)
{
setup
()
defer
teardown
()
input
:=
&
Membership
{
State
:
String
(
"active"
)}
mux
.
HandleFunc
(
"/orgs/o/memberships/u"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
v
:=
new
(
Membership
)
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
v
)
testMethod
(
t
,
r
,
"PATCH"
)
if
!
reflect
.
DeepEqual
(
v
,
input
)
{
t
.
Errorf
(
"Request body = %+v, want %+v"
,
v
,
input
)
}
fmt
.
Fprint
(
w
,
`{"url":"u"}`
)
})
membership
,
_
,
err
:=
client
.
Organizations
.
EditOrgMembership
(
"u"
,
"o"
,
input
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Organizations.EditOrgMembership returned error: %v"
,
err
)
t
.
Errorf
(
"Organizations.EditOrgMembership returned error: %v"
,
err
)
}
}
...
@@ -287,3 +339,18 @@ func TestOrganizationsService_EditOrgMembership(t *testing.T) {
...
@@ -287,3 +339,18 @@ func TestOrganizationsService_EditOrgMembership(t *testing.T) {
t
.
Errorf
(
"Organizations.EditOrgMembership returned %+v, want %+v"
,
membership
,
want
)
t
.
Errorf
(
"Organizations.EditOrgMembership returned %+v, want %+v"
,
membership
,
want
)
}
}
}
}
func
TestOrganizationsService_RemoveOrgMembership
(
t
*
testing
.
T
)
{
setup
()
defer
teardown
()
mux
.
HandleFunc
(
"/orgs/o/memberships/u"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"DELETE"
)
w
.
WriteHeader
(
http
.
StatusNoContent
)
})
_
,
err
:=
client
.
Organizations
.
RemoveOrgMembership
(
"u"
,
"o"
)
if
err
!=
nil
{
t
.
Errorf
(
"Organizations.RemoveOrgMembership returned error: %v"
,
err
)
}
}
Godeps/_workspace/src/github.com/google/go-github/github/orgs_teams.go
View file @
39735939
...
@@ -10,11 +10,25 @@ import "fmt"
...
@@ -10,11 +10,25 @@ import "fmt"
// Team represents a team within a GitHub organization. Teams are used to
// Team represents a team within a GitHub organization. Teams are used to
// manage access to an organization's repositories.
// manage access to an organization's repositories.
type
Team
struct
{
type
Team
struct
{
ID
*
int
`json:"id,omitempty"`
ID
*
int
`json:"id,omitempty"`
Name
*
string
`json:"name,omitempty"`
Name
*
string
`json:"name,omitempty"`
URL
*
string
`json:"url,omitempty"`
URL
*
string
`json:"url,omitempty"`
Slug
*
string
`json:"slug,omitempty"`
Slug
*
string
`json:"slug,omitempty"`
Permission
*
string
`json:"permission,omitempty"`
// Permission is deprecated when creating or editing a team in an org
// using the new GitHub permission model. It no longer identifies the
// permission a team has on its repos, but only specifies the default
// permission a repo is initially added with. Avoid confusion by
// specifying a permission value when calling AddTeamRepo.
Permission
*
string
`json:"permission,omitempty"`
// Privacy identifies the level of privacy this team should have.
// Possible values are:
// secret - only visible to organization owners and members of this team
// closed - visible to all members of this organization
// Default is "secret".
Privacy
*
string
`json:"privacy,omitempty"`
MembersCount
*
int
`json:"members_count,omitempty"`
MembersCount
*
int
`json:"members_count,omitempty"`
ReposCount
*
int
`json:"repos_count,omitempty"`
ReposCount
*
int
`json:"repos_count,omitempty"`
Organization
*
Organization
`json:"organization,omitempty"`
Organization
*
Organization
`json:"organization,omitempty"`
...
@@ -77,6 +91,10 @@ func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, *Respo
...
@@ -77,6 +91,10 @@ func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, *Respo
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
if
team
.
Privacy
!=
nil
{
req
.
Header
.
Set
(
"Accept"
,
mediaTypeOrgPermissionPreview
)
}
t
:=
new
(
Team
)
t
:=
new
(
Team
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
t
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
t
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -96,6 +114,10 @@ func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, *Response, e
...
@@ -96,6 +114,10 @@ func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, *Response, e
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
if
team
.
Privacy
!=
nil
{
req
.
Header
.
Set
(
"Accept"
,
mediaTypeOrgPermissionPreview
)
}
t
:=
new
(
Team
)
t
:=
new
(
Team
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
t
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
t
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -118,11 +140,21 @@ func (s *OrganizationsService) DeleteTeam(team int) (*Response, error) {
...
@@ -118,11 +140,21 @@ func (s *OrganizationsService) DeleteTeam(team int) (*Response, error) {
return
s
.
client
.
Do
(
req
,
nil
)
return
s
.
client
.
Do
(
req
,
nil
)
}
}
// OrganizationListTeamMembersOptions specifies the optional parameters to the
// OrganizationsService.ListTeamMembers method.
type
OrganizationListTeamMembersOptions
struct
{
// Role filters members returned by their role in the team. Possible
// values are "all", "member", "maintainer". Default is "all".
Role
string
`url:"role,omitempty"`
ListOptions
}
// ListTeamMembers lists all of the users who are members of the specified
// ListTeamMembers lists all of the users who are members of the specified
// team.
// team.
//
//
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-team-members
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-team-members
func
(
s
*
OrganizationsService
)
ListTeamMembers
(
team
int
,
opt
*
List
Options
)
([]
User
,
*
Response
,
error
)
{
func
(
s
*
OrganizationsService
)
ListTeamMembers
(
team
int
,
opt
*
OrganizationListTeamMembers
Options
)
([]
User
,
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"teams/%v/members"
,
team
)
u
:=
fmt
.
Sprintf
(
"teams/%v/members"
,
team
)
u
,
err
:=
addOptions
(
u
,
opt
)
u
,
err
:=
addOptions
(
u
,
opt
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -134,6 +166,10 @@ func (s *OrganizationsService) ListTeamMembers(team int, opt *ListOptions) ([]Us
...
@@ -134,6 +166,10 @@ func (s *OrganizationsService) ListTeamMembers(team int, opt *ListOptions) ([]Us
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
if
opt
!=
nil
&&
opt
.
Role
!=
""
{
req
.
Header
.
Set
(
"Accept"
,
mediaTypeOrgPermissionPreview
)
}
members
:=
new
([]
User
)
members
:=
new
([]
User
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
members
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
members
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -182,19 +218,40 @@ func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]Repo
...
@@ -182,19 +218,40 @@ func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]Repo
return
*
repos
,
resp
,
err
return
*
repos
,
resp
,
err
}
}
// IsTeamRepo checks if a team manages the specified repository.
// IsTeamRepo checks if a team manages the specified repository. If the
// repository is managed by team, a Repository is returned which includes the
// permissions team has for that repo.
//
//
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#get-team-repo
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#get-team-repo
func
(
s
*
OrganizationsService
)
IsTeamRepo
(
team
int
,
owner
string
,
repo
string
)
(
bool
,
*
Response
,
error
)
{
func
(
s
*
OrganizationsService
)
IsTeamRepo
(
team
int
,
owner
string
,
repo
string
)
(
*
Repository
,
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"teams/%v/repos/%v/%v"
,
team
,
owner
,
repo
)
u
:=
fmt
.
Sprintf
(
"teams/%v/repos/%v/%v"
,
team
,
owner
,
repo
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
nil
,
err
return
nil
,
nil
,
err
}
}
resp
,
err
:=
s
.
client
.
Do
(
req
,
nil
)
req
.
Header
.
Set
(
"Accept"
,
mediaTypeOrgPermissionRepoPreview
)
manages
,
err
:=
parseBoolResponse
(
err
)
return
manages
,
resp
,
err
repository
:=
new
(
Repository
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
repository
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
repository
,
resp
,
err
}
// OrganizationAddTeamRepoOptions specifies the optional parameters to the
// OrganizationsService.AddTeamRepo method.
type
OrganizationAddTeamRepoOptions
struct
{
// Permission specifies the permission to grant the team on this repository.
// Possible values are:
// pull - team members can pull, but not push to or administer this repository
// push - team members can pull and push, but not administer this repository
// admin - team members can pull, push and administer this repository
//
// If not specified, the team's permission attribute will be used.
Permission
string
`json:"permission,omitempty"`
}
}
// AddTeamRepo adds a repository to be managed by the specified team. The
// AddTeamRepo adds a repository to be managed by the specified team. The
...
@@ -202,13 +259,17 @@ func (s *OrganizationsService) IsTeamRepo(team int, owner string, repo string) (
...
@@ -202,13 +259,17 @@ func (s *OrganizationsService) IsTeamRepo(team int, owner string, repo string) (
// belongs, or a direct fork of a repository owned by the organization.
// belongs, or a direct fork of a repository owned by the organization.
//
//
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#add-team-repo
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#add-team-repo
func
(
s
*
OrganizationsService
)
AddTeamRepo
(
team
int
,
owner
string
,
repo
string
)
(
*
Response
,
error
)
{
func
(
s
*
OrganizationsService
)
AddTeamRepo
(
team
int
,
owner
string
,
repo
string
,
opt
*
OrganizationAddTeamRepoOptions
)
(
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"teams/%v/repos/%v/%v"
,
team
,
owner
,
repo
)
u
:=
fmt
.
Sprintf
(
"teams/%v/repos/%v/%v"
,
team
,
owner
,
repo
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
nil
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
opt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
opt
!=
nil
{
req
.
Header
.
Set
(
"Accept"
,
mediaTypeOrgPermissionPreview
)
}
return
s
.
client
.
Do
(
req
,
nil
)
return
s
.
client
.
Do
(
req
,
nil
)
}
}
...
@@ -269,6 +330,20 @@ func (s *OrganizationsService) GetTeamMembership(team int, user string) (*Member
...
@@ -269,6 +330,20 @@ func (s *OrganizationsService) GetTeamMembership(team int, user string) (*Member
return
t
,
resp
,
err
return
t
,
resp
,
err
}
}
// OrganizationAddTeamMembershipOptions does stuff specifies the optional
// parameters to the OrganizationsService.AddTeamMembership method.
type
OrganizationAddTeamMembershipOptions
struct
{
// Role specifies the role the user should have in the team. Possible
// values are:
// member - a normal member of the team
// maintainer - a team maintainer. Able to add/remove other team
// members, promote other team members to team
// maintainer, and edit the team’s name and description
//
// Default value is "member".
Role
string
`json:"role,omitempty"`
}
// AddTeamMembership adds or invites a user to a team.
// AddTeamMembership adds or invites a user to a team.
//
//
// In order to add a membership between a user and a team, the authenticated
// In order to add a membership between a user and a team, the authenticated
...
@@ -287,13 +362,17 @@ func (s *OrganizationsService) GetTeamMembership(team int, user string) (*Member
...
@@ -287,13 +362,17 @@ func (s *OrganizationsService) GetTeamMembership(team int, user string) (*Member
// added as a member of the team.
// added as a member of the team.
//
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#add-team-membership
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#add-team-membership
func
(
s
*
OrganizationsService
)
AddTeamMembership
(
team
int
,
user
string
)
(
*
Membership
,
*
Response
,
error
)
{
func
(
s
*
OrganizationsService
)
AddTeamMembership
(
team
int
,
user
string
,
opt
*
OrganizationAddTeamMembershipOptions
)
(
*
Membership
,
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"teams/%v/memberships/%v"
,
team
,
user
)
u
:=
fmt
.
Sprintf
(
"teams/%v/memberships/%v"
,
team
,
user
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
nil
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
opt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
if
opt
!=
nil
{
req
.
Header
.
Set
(
"Accept"
,
mediaTypeOrgPermissionPreview
)
}
t
:=
new
(
Membership
)
t
:=
new
(
Membership
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
t
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
t
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
Godeps/_workspace/src/github.com/google/go-github/github/orgs_teams_test.go
View file @
39735939
...
@@ -64,13 +64,14 @@ func TestOrganizationsService_CreateTeam(t *testing.T) {
...
@@ -64,13 +64,14 @@ func TestOrganizationsService_CreateTeam(t *testing.T) {
setup
()
setup
()
defer
teardown
()
defer
teardown
()
input
:=
&
Team
{
Name
:
String
(
"n"
)}
input
:=
&
Team
{
Name
:
String
(
"n"
)
,
Privacy
:
String
(
"closed"
)
}
mux
.
HandleFunc
(
"/orgs/o/teams"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/orgs/o/teams"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
v
:=
new
(
Team
)
v
:=
new
(
Team
)
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
v
)
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
v
)
testMethod
(
t
,
r
,
"POST"
)
testMethod
(
t
,
r
,
"POST"
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeOrgPermissionPreview
)
if
!
reflect
.
DeepEqual
(
v
,
input
)
{
if
!
reflect
.
DeepEqual
(
v
,
input
)
{
t
.
Errorf
(
"Request body = %+v, want %+v"
,
v
,
input
)
t
.
Errorf
(
"Request body = %+v, want %+v"
,
v
,
input
)
}
}
...
@@ -98,13 +99,14 @@ func TestOrganizationsService_EditTeam(t *testing.T) {
...
@@ -98,13 +99,14 @@ func TestOrganizationsService_EditTeam(t *testing.T) {
setup
()
setup
()
defer
teardown
()
defer
teardown
()
input
:=
&
Team
{
Name
:
String
(
"n"
)}
input
:=
&
Team
{
Name
:
String
(
"n"
)
,
Privacy
:
String
(
"closed"
)
}
mux
.
HandleFunc
(
"/teams/1"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/teams/1"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
v
:=
new
(
Team
)
v
:=
new
(
Team
)
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
v
)
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
v
)
testMethod
(
t
,
r
,
"PATCH"
)
testMethod
(
t
,
r
,
"PATCH"
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeOrgPermissionPreview
)
if
!
reflect
.
DeepEqual
(
v
,
input
)
{
if
!
reflect
.
DeepEqual
(
v
,
input
)
{
t
.
Errorf
(
"Request body = %+v, want %+v"
,
v
,
input
)
t
.
Errorf
(
"Request body = %+v, want %+v"
,
v
,
input
)
}
}
...
@@ -143,11 +145,12 @@ func TestOrganizationsService_ListTeamMembers(t *testing.T) {
...
@@ -143,11 +145,12 @@ func TestOrganizationsService_ListTeamMembers(t *testing.T) {
mux
.
HandleFunc
(
"/teams/1/members"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/teams/1/members"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
testMethod
(
t
,
r
,
"GET"
)
testFormValues
(
t
,
r
,
values
{
"page"
:
"2"
})
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeOrgPermissionPreview
)
testFormValues
(
t
,
r
,
values
{
"role"
:
"member"
,
"page"
:
"2"
})
fmt
.
Fprint
(
w
,
`[{"id":1}]`
)
fmt
.
Fprint
(
w
,
`[{"id":1}]`
)
})
})
opt
:=
&
ListOptions
{
Page
:
2
}
opt
:=
&
OrganizationListTeamMembersOptions
{
Role
:
"member"
,
ListOptions
:
ListOptions
{
Page
:
2
}
}
members
,
_
,
err
:=
client
.
Organizations
.
ListTeamMembers
(
1
,
opt
)
members
,
_
,
err
:=
client
.
Organizations
.
ListTeamMembers
(
1
,
opt
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Organizations.ListTeamMembers returned error: %v"
,
err
)
t
.
Errorf
(
"Organizations.ListTeamMembers returned error: %v"
,
err
)
...
@@ -288,15 +291,18 @@ func TestOrganizationsService_IsTeamRepo_true(t *testing.T) {
...
@@ -288,15 +291,18 @@ func TestOrganizationsService_IsTeamRepo_true(t *testing.T) {
mux
.
HandleFunc
(
"/teams/1/repos/o/r"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/teams/1/repos/o/r"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
testMethod
(
t
,
r
,
"GET"
)
w
.
WriteHeader
(
http
.
StatusNoContent
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeOrgPermissionRepoPreview
)
fmt
.
Fprint
(
w
,
`{"id":1}`
)
})
})
managed
,
_
,
err
:=
client
.
Organizations
.
IsTeamRepo
(
1
,
"o"
,
"r"
)
repo
,
_
,
err
:=
client
.
Organizations
.
IsTeamRepo
(
1
,
"o"
,
"r"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Organizations.IsTeamRepo returned error: %v"
,
err
)
t
.
Errorf
(
"Organizations.IsTeamRepo returned error: %v"
,
err
)
}
}
if
want
:=
true
;
managed
!=
want
{
t
.
Errorf
(
"Organizations.IsTeamRepo returned %+v, want %+v"
,
managed
,
want
)
want
:=
&
Repository
{
ID
:
Int
(
1
)}
if
!
reflect
.
DeepEqual
(
repo
,
want
)
{
t
.
Errorf
(
"Organizations.IsTeamRepo returned %+v, want %+v"
,
repo
,
want
)
}
}
}
}
...
@@ -309,12 +315,15 @@ func TestOrganizationsService_IsTeamRepo_false(t *testing.T) {
...
@@ -309,12 +315,15 @@ func TestOrganizationsService_IsTeamRepo_false(t *testing.T) {
w
.
WriteHeader
(
http
.
StatusNotFound
)
w
.
WriteHeader
(
http
.
StatusNotFound
)
})
})
managed
,
_
,
err
:=
client
.
Organizations
.
IsTeamRepo
(
1
,
"o"
,
"r"
)
repo
,
resp
,
err
:=
client
.
Organizations
.
IsTeamRepo
(
1
,
"o"
,
"r"
)
if
err
!
=
nil
{
if
err
=
=
nil
{
t
.
Errorf
(
"
Organizations.IsTeamRepo returned error: %v"
,
err
)
t
.
Errorf
(
"
Expected HTTP 404 response"
)
}
}
if
want
:=
false
;
managed
!=
want
{
if
got
,
want
:=
resp
.
Response
.
StatusCode
,
http
.
StatusNotFound
;
got
!=
want
{
t
.
Errorf
(
"Organizations.IsTeamRepo returned %+v, want %+v"
,
managed
,
want
)
t
.
Errorf
(
"Organizations.IsTeamRepo returned status %d, want %d"
,
got
,
want
)
}
if
repo
!=
nil
{
t
.
Errorf
(
"Organizations.IsTeamRepo returned %+v, want nil"
,
repo
)
}
}
}
}
...
@@ -327,12 +336,15 @@ func TestOrganizationsService_IsTeamRepo_error(t *testing.T) {
...
@@ -327,12 +336,15 @@ func TestOrganizationsService_IsTeamRepo_error(t *testing.T) {
http
.
Error
(
w
,
"BadRequest"
,
http
.
StatusBadRequest
)
http
.
Error
(
w
,
"BadRequest"
,
http
.
StatusBadRequest
)
})
})
managed
,
_
,
err
:=
client
.
Organizations
.
IsTeamRepo
(
1
,
"o"
,
"r"
)
repo
,
resp
,
err
:=
client
.
Organizations
.
IsTeamRepo
(
1
,
"o"
,
"r"
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"Expected HTTP 400 response"
)
t
.
Errorf
(
"Expected HTTP 400 response"
)
}
}
if
want
:=
false
;
managed
!=
want
{
if
got
,
want
:=
resp
.
Response
.
StatusCode
,
http
.
StatusBadRequest
;
got
!=
want
{
t
.
Errorf
(
"Organizations.IsTeamRepo returned %+v, want %+v"
,
managed
,
want
)
t
.
Errorf
(
"Organizations.IsTeamRepo returned status %d, want %d"
,
got
,
want
)
}
if
repo
!=
nil
{
t
.
Errorf
(
"Organizations.IsTeamRepo returned %+v, want nil"
,
repo
)
}
}
}
}
...
@@ -345,12 +357,22 @@ func TestOrganizationsService_AddTeamRepo(t *testing.T) {
...
@@ -345,12 +357,22 @@ func TestOrganizationsService_AddTeamRepo(t *testing.T) {
setup
()
setup
()
defer
teardown
()
defer
teardown
()
opt
:=
&
OrganizationAddTeamRepoOptions
{
Permission
:
"admin"
}
mux
.
HandleFunc
(
"/teams/1/repos/o/r"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/teams/1/repos/o/r"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
v
:=
new
(
OrganizationAddTeamRepoOptions
)
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
v
)
testMethod
(
t
,
r
,
"PUT"
)
testMethod
(
t
,
r
,
"PUT"
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeOrgPermissionPreview
)
if
!
reflect
.
DeepEqual
(
v
,
opt
)
{
t
.
Errorf
(
"Request body = %+v, want %+v"
,
v
,
opt
)
}
w
.
WriteHeader
(
http
.
StatusNoContent
)
w
.
WriteHeader
(
http
.
StatusNoContent
)
})
})
_
,
err
:=
client
.
Organizations
.
AddTeamRepo
(
1
,
"o"
,
"r"
)
_
,
err
:=
client
.
Organizations
.
AddTeamRepo
(
1
,
"o"
,
"r"
,
opt
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Organizations.AddTeamRepo returned error: %v"
,
err
)
t
.
Errorf
(
"Organizations.AddTeamRepo returned error: %v"
,
err
)
}
}
...
@@ -365,14 +387,14 @@ func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) {
...
@@ -365,14 +387,14 @@ func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) {
w
.
WriteHeader
(
422
)
w
.
WriteHeader
(
422
)
})
})
_
,
err
:=
client
.
Organizations
.
AddTeamRepo
(
1
,
"o"
,
"r"
)
_
,
err
:=
client
.
Organizations
.
AddTeamRepo
(
1
,
"o"
,
"r"
,
nil
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"Expcted error to be returned"
)
t
.
Errorf
(
"Expcted error to be returned"
)
}
}
}
}
func
TestOrganizationsService_AddTeamRepo_invalidOwner
(
t
*
testing
.
T
)
{
func
TestOrganizationsService_AddTeamRepo_invalidOwner
(
t
*
testing
.
T
)
{
_
,
err
:=
client
.
Organizations
.
AddTeamRepo
(
1
,
"%"
,
"r"
)
_
,
err
:=
client
.
Organizations
.
AddTeamRepo
(
1
,
"%"
,
"r"
,
nil
)
testURLParseError
(
t
,
err
)
testURLParseError
(
t
,
err
)
}
}
...
@@ -420,12 +442,22 @@ func TestOrganizationsService_AddTeamMembership(t *testing.T) {
...
@@ -420,12 +442,22 @@ func TestOrganizationsService_AddTeamMembership(t *testing.T) {
setup
()
setup
()
defer
teardown
()
defer
teardown
()
opt
:=
&
OrganizationAddTeamMembershipOptions
{
Role
:
"maintainer"
}
mux
.
HandleFunc
(
"/teams/1/memberships/u"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/teams/1/memberships/u"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
v
:=
new
(
OrganizationAddTeamMembershipOptions
)
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
v
)
testMethod
(
t
,
r
,
"PUT"
)
testMethod
(
t
,
r
,
"PUT"
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeOrgPermissionPreview
)
if
!
reflect
.
DeepEqual
(
v
,
opt
)
{
t
.
Errorf
(
"Request body = %+v, want %+v"
,
v
,
opt
)
}
fmt
.
Fprint
(
w
,
`{"url":"u", "state":"pending"}`
)
fmt
.
Fprint
(
w
,
`{"url":"u", "state":"pending"}`
)
})
})
membership
,
_
,
err
:=
client
.
Organizations
.
AddTeamMembership
(
1
,
"u"
)
membership
,
_
,
err
:=
client
.
Organizations
.
AddTeamMembership
(
1
,
"u"
,
opt
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Organizations.AddTeamMembership returned error: %v"
,
err
)
t
.
Errorf
(
"Organizations.AddTeamMembership returned error: %v"
,
err
)
}
}
...
...
Godeps/_workspace/src/github.com/google/go-github/github/pulls_comments.go
View file @
39735939
...
@@ -93,7 +93,7 @@ func (s *PullRequestsService) GetComment(owner string, repo string, number int)
...
@@ -93,7 +93,7 @@ func (s *PullRequestsService) GetComment(owner string, repo string, number int)
// CreateComment creates a new comment on the specified pull request.
// CreateComment creates a new comment on the specified pull request.
//
//
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#
get-a-single
-comment
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#
create-a
-comment
func
(
s
*
PullRequestsService
)
CreateComment
(
owner
string
,
repo
string
,
number
int
,
comment
*
PullRequestComment
)
(
*
PullRequestComment
,
*
Response
,
error
)
{
func
(
s
*
PullRequestsService
)
CreateComment
(
owner
string
,
repo
string
,
number
int
,
comment
*
PullRequestComment
)
(
*
PullRequestComment
,
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"repos/%v/%v/pulls/%d/comments"
,
owner
,
repo
,
number
)
u
:=
fmt
.
Sprintf
(
"repos/%v/%v/pulls/%d/comments"
,
owner
,
repo
,
number
)
req
,
err
:=
s
.
client
.
NewRequest
(
"POST"
,
u
,
comment
)
req
,
err
:=
s
.
client
.
NewRequest
(
"POST"
,
u
,
comment
)
...
...
Godeps/_workspace/src/github.com/google/go-github/github/repos_collaborators.go
View file @
39735939
...
@@ -22,6 +22,8 @@ func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOpt
...
@@ -22,6 +22,8 @@ func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOpt
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
req
.
Header
.
Set
(
"Accept"
,
mediaTypeOrgPermissionPreview
)
users
:=
new
([]
User
)
users
:=
new
([]
User
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
users
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
users
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -49,15 +51,33 @@ func (s *RepositoriesService) IsCollaborator(owner, repo, user string) (bool, *R
...
@@ -49,15 +51,33 @@ func (s *RepositoriesService) IsCollaborator(owner, repo, user string) (bool, *R
return
isCollab
,
resp
,
err
return
isCollab
,
resp
,
err
}
}
// RepositoryAddCollaboratorOptions specifies the optional parameters to the
// RepositoriesService.AddCollaborator method.
type
RepositoryAddCollaboratorOptions
struct
{
// Permission specifies the permission to grant the user on this repository.
// Possible values are:
// pull - team members can pull, but not push to or administer this repository
// push - team members can pull and push, but not administer this repository
// admin - team members can pull, push and administer this repository
//
// Default value is "pull". This option is only valid for organization-owned repositories.
Permission
string
`json:"permission,omitempty"`
}
// AddCollaborator adds the specified Github user as collaborator to the given repo.
// AddCollaborator adds the specified Github user as collaborator to the given repo.
//
//
// GitHub API docs: http://developer.github.com/v3/repos/collaborators/#add-collaborator
// GitHub API docs: http://developer.github.com/v3/repos/collaborators/#add-collaborator
func
(
s
*
RepositoriesService
)
AddCollaborator
(
owner
,
repo
,
user
string
)
(
*
Response
,
error
)
{
func
(
s
*
RepositoriesService
)
AddCollaborator
(
owner
,
repo
,
user
string
,
opt
*
RepositoryAddCollaboratorOptions
)
(
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"repos/%v/%v/collaborators/%v"
,
owner
,
repo
,
user
)
u
:=
fmt
.
Sprintf
(
"repos/%v/%v/collaborators/%v"
,
owner
,
repo
,
user
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
nil
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
opt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
opt
!=
nil
{
req
.
Header
.
Set
(
"Accept"
,
mediaTypeOrgPermissionPreview
)
}
return
s
.
client
.
Do
(
req
,
nil
)
return
s
.
client
.
Do
(
req
,
nil
)
}
}
...
...
Godeps/_workspace/src/github.com/google/go-github/github/repos_collaborators_test.go
View file @
39735939
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
package
github
package
github
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"net/http"
"net/http"
"reflect"
"reflect"
...
@@ -18,6 +19,7 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) {
...
@@ -18,6 +19,7 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) {
mux
.
HandleFunc
(
"/repos/o/r/collaborators"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/repos/o/r/collaborators"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
testMethod
(
t
,
r
,
"GET"
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeOrgPermissionPreview
)
testFormValues
(
t
,
r
,
values
{
"page"
:
"2"
})
testFormValues
(
t
,
r
,
values
{
"page"
:
"2"
})
fmt
.
Fprintf
(
w
,
`[{"id":1}, {"id":2}]`
)
fmt
.
Fprintf
(
w
,
`[{"id":1}, {"id":2}]`
)
})
})
...
@@ -86,19 +88,29 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) {
...
@@ -86,19 +88,29 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) {
setup
()
setup
()
defer
teardown
()
defer
teardown
()
opt
:=
&
RepositoryAddCollaboratorOptions
{
Permission
:
"admin"
}
mux
.
HandleFunc
(
"/repos/o/r/collaborators/u"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
HandleFunc
(
"/repos/o/r/collaborators/u"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
v
:=
new
(
RepositoryAddCollaboratorOptions
)
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
v
)
testMethod
(
t
,
r
,
"PUT"
)
testMethod
(
t
,
r
,
"PUT"
)
testHeader
(
t
,
r
,
"Accept"
,
mediaTypeOrgPermissionPreview
)
if
!
reflect
.
DeepEqual
(
v
,
opt
)
{
t
.
Errorf
(
"Request body = %+v, want %+v"
,
v
,
opt
)
}
w
.
WriteHeader
(
http
.
StatusNoContent
)
w
.
WriteHeader
(
http
.
StatusNoContent
)
})
})
_
,
err
:=
client
.
Repositories
.
AddCollaborator
(
"o"
,
"r"
,
"u"
)
_
,
err
:=
client
.
Repositories
.
AddCollaborator
(
"o"
,
"r"
,
"u"
,
opt
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Repositories.AddCollaborator returned error: %v"
,
err
)
t
.
Errorf
(
"Repositories.AddCollaborator returned error: %v"
,
err
)
}
}
}
}
func
TestRepositoriesService_AddCollaborator_invalidUser
(
t
*
testing
.
T
)
{
func
TestRepositoriesService_AddCollaborator_invalidUser
(
t
*
testing
.
T
)
{
_
,
err
:=
client
.
Repositories
.
AddCollaborator
(
"%"
,
"%"
,
"%"
)
_
,
err
:=
client
.
Repositories
.
AddCollaborator
(
"%"
,
"%"
,
"%"
,
nil
)
testURLParseError
(
t
,
err
)
testURLParseError
(
t
,
err
)
}
}
...
...
Godeps/_workspace/src/github.com/google/go-github/github/repos_releases.go
View file @
39735939
...
@@ -85,8 +85,27 @@ func (s *RepositoriesService) ListReleases(owner, repo string, opt *ListOptions)
...
@@ -85,8 +85,27 @@ func (s *RepositoriesService) ListReleases(owner, repo string, opt *ListOptions)
// GitHub API docs: http://developer.github.com/v3/repos/releases/#get-a-single-release
// GitHub API docs: http://developer.github.com/v3/repos/releases/#get-a-single-release
func
(
s
*
RepositoriesService
)
GetRelease
(
owner
,
repo
string
,
id
int
)
(
*
RepositoryRelease
,
*
Response
,
error
)
{
func
(
s
*
RepositoriesService
)
GetRelease
(
owner
,
repo
string
,
id
int
)
(
*
RepositoryRelease
,
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"repos/%s/%s/releases/%d"
,
owner
,
repo
,
id
)
u
:=
fmt
.
Sprintf
(
"repos/%s/%s/releases/%d"
,
owner
,
repo
,
id
)
return
s
.
getSingleRelease
(
u
)
}
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
)
// GetLatestRelease fetches the latest published release for the repository.
//
// GitHub API docs: https://developer.github.com/v3/repos/releases/#get-the-latest-release
func
(
s
*
RepositoriesService
)
GetLatestRelease
(
owner
,
repo
string
)
(
*
RepositoryRelease
,
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"repos/%s/%s/releases/latest"
,
owner
,
repo
)
return
s
.
getSingleRelease
(
u
)
}
// GetReleaseByTag fetches a release with the specified tag.
//
// GitHub API docs: https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name
func
(
s
*
RepositoriesService
)
GetReleaseByTag
(
owner
,
repo
,
tag
string
)
(
*
RepositoryRelease
,
*
Response
,
error
)
{
u
:=
fmt
.
Sprintf
(
"repos/%s/%s/releases/tags/%s"
,
owner
,
repo
,
tag
)
return
s
.
getSingleRelease
(
u
)
}
func
(
s
*
RepositoriesService
)
getSingleRelease
(
url
string
)
(
*
RepositoryRelease
,
*
Response
,
error
)
{
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
url
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
...
Godeps/_workspace/src/github.com/google/go-github/github/repos_releases_test.go
View file @
39735939
...
@@ -55,6 +55,46 @@ func TestRepositoriesService_GetRelease(t *testing.T) {
...
@@ -55,6 +55,46 @@ func TestRepositoriesService_GetRelease(t *testing.T) {
}
}
}
}
func
TestRepositoriesService_GetLatestRelease
(
t
*
testing
.
T
)
{
setup
()
defer
teardown
()
mux
.
HandleFunc
(
"/repos/o/r/releases/latest"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprint
(
w
,
`{"id":3}`
)
})
release
,
resp
,
err
:=
client
.
Repositories
.
GetLatestRelease
(
"o"
,
"r"
)
if
err
!=
nil
{
t
.
Errorf
(
"Repositories.GetLatestRelease returned error: %v
\n
%v"
,
err
,
resp
.
Body
)
}
want
:=
&
RepositoryRelease
{
ID
:
Int
(
3
)}
if
!
reflect
.
DeepEqual
(
release
,
want
)
{
t
.
Errorf
(
"Repositories.GetLatestRelease returned %+v, want %+v"
,
release
,
want
)
}
}
func
TestRepositoriesService_GetReleaseByTag
(
t
*
testing
.
T
)
{
setup
()
defer
teardown
()
mux
.
HandleFunc
(
"/repos/o/r/releases/tags/foo"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprint
(
w
,
`{"id":13}`
)
})
release
,
resp
,
err
:=
client
.
Repositories
.
GetReleaseByTag
(
"o"
,
"r"
,
"foo"
)
if
err
!=
nil
{
t
.
Errorf
(
"Repositories.GetReleaseByTag returned error: %v
\n
%v"
,
err
,
resp
.
Body
)
}
want
:=
&
RepositoryRelease
{
ID
:
Int
(
13
)}
if
!
reflect
.
DeepEqual
(
release
,
want
)
{
t
.
Errorf
(
"Repositories.GetReleaseByTag returned %+v, want %+v"
,
release
,
want
)
}
}
func
TestRepositoriesService_CreateRelease
(
t
*
testing
.
T
)
{
func
TestRepositoriesService_CreateRelease
(
t
*
testing
.
T
)
{
setup
()
setup
()
defer
teardown
()
defer
teardown
()
...
...
Godeps/_workspace/src/github.com/google/go-github/github/repos_test.go
View file @
39735939
...
@@ -45,7 +45,6 @@ func TestRepositoriesService_List_specifiedUser(t *testing.T) {
...
@@ -45,7 +45,6 @@ func TestRepositoriesService_List_specifiedUser(t *testing.T) {
"direction"
:
"asc"
,
"direction"
:
"asc"
,
"page"
:
"2"
,
"page"
:
"2"
,
})
})
fmt
.
Fprint
(
w
,
`[{"id":1}]`
)
fmt
.
Fprint
(
w
,
`[{"id":1}]`
)
})
})
...
...
Godeps/_workspace/src/github.com/google/go-github/github/users.go
View file @
39735939
...
@@ -59,6 +59,10 @@ type User struct {
...
@@ -59,6 +59,10 @@ type User struct {
// TextMatches is only populated from search results that request text matches
// TextMatches is only populated from search results that request text matches
// See: search.go and https://developer.github.com/v3/search/#text-match-metadata
// See: search.go and https://developer.github.com/v3/search/#text-match-metadata
TextMatches
[]
TextMatch
`json:"text_matches,omitempty"`
TextMatches
[]
TextMatch
`json:"text_matches,omitempty"`
// Permissions identifies the permissions that a user has on a given
// repository. This is only populated when calling Repositories.ListCollaborators.
Permissions
*
map
[
string
]
bool
`json:"permissions,omitempty"`
}
}
func
(
u
User
)
String
()
string
{
func
(
u
User
)
String
()
string
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment