-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement/add remove repository #749
Merged
dmitshur
merged 41 commits into
google:master
from
MorrisLaw:enhancement/add-remove-repository
Oct 13, 2017
Merged
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
aa10fb4
Added my name to AUTHORS list.
MorrisLaw 7772ba0
Added API route for adding a repo to an installation.
MorrisLaw 5d99cdf
Added api route for removing repo from installation.
MorrisLaw 2eab2b3
Moved Add/Remove Repository functions to app_installation.
MorrisLaw a35a566
Simplified logic in remove repository.
MorrisLaw 3e14143
Style fix.
MorrisLaw 44e0f51
Refactored function names.
MorrisLaw defe8b8
Renamed functions back to having Repository suffix.
MorrisLaw f31595a
Change argument from Installation to Repository.
MorrisLaw 5934515
Changed variable name for Repository.
MorrisLaw e20f019
Shortened function name.
MorrisLaw 16bcc33
Added tests for Add and Remove repo.
MorrisLaw f90fa0d
Fixed golint issues.
MorrisLaw 71f1694
Merge remote-tracking branch 'origin/master' into enhancement/add-rem…
MorrisLaw 585efab
Removed merge conflict from adding my name to list.
MorrisLaw 030ae55
Ran `go fmt` on file.
MorrisLaw 11aefc3
Ran `go fmt` on file.
MorrisLaw 173da1c
Changed s *AppService to s *AppsService .
MorrisLaw 2c3db48
Added import and removed extra value from return in removeRepo.
MorrisLaw 158fea8
Fixed some issues discovered by `go test` .
MorrisLaw 0c7acc2
Merge branch 'master' into enhancement/add-remove-repository
MorrisLaw 9b8d40c
Merge remote-tracking branch 'upstream/master' into enhancement/add-r…
b9c5873
Added colons to url path for add and remove repo.
e132615
Removed colons from http put/delete paths.
926a90c
Debugging broken test and using example from repos_test as building b…
f1bf61b
Merge branch 'master' into enhancement/add-remove-repository
MorrisLaw 5e8d98c
Merge branch 'enhancement/add-remove-repository' of https://github.co…
MorrisLaw a612b5e
Refactored url string.
MorrisLaw f35c3c9
Add repo test passes.
d6c991e
Uncommented custom accept header.
4d5820a
Refactored method signatures add and remove repo. Added response chec…
b2f7773
Merge branch 'enhancement/add-remove-repository' of https://github.co…
60af6e6
Ran go fmt on codebase.
8e876e4
Removed unnecessary import and changed *github.ErrorResponse to *Erro…
42faa4d
Fixed url path for RemoveRepo and removed extra conditional in Remove…
326457b
Added newline at eof, to restart build after CLA email fix.
MorrisLaw b4b56c3
Removed newline from test file.
MorrisLaw 432dab7
Fixed suggestions for naming functions, and fixing error check.
c01f313
Added full function names to Errorf strings, to match referenced func…
41d02d7
Removed mediatypev3.
b5f3a3b
Removed starting slash in URLs.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ | |
|
||
package github | ||
|
||
import "context" | ||
import ( | ||
"context" | ||
"fmt" | ||
) | ||
|
||
// Installation represents a GitHub Apps installation. | ||
type Installation struct { | ||
|
@@ -47,3 +50,35 @@ func (s *AppsService) ListRepos(ctx context.Context, opt *ListOptions) ([]*Repos | |
|
||
return r.Repositories, resp, nil | ||
} | ||
|
||
// AddRepository adds a single repository to an installation. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/apps/installations/#add-repository-to-installation | ||
func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int) (*Repository, *Response, error) { | ||
u := fmt.Sprintf("/apps/installations/%v/repositories/%v", instID, repoID) | ||
req, err := s.client.NewRequest("PUT", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
r := new(Repository) | ||
resp, err := s.client.Do(ctx, req, r) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return r, resp, nil | ||
} | ||
|
||
// RemoveRepository removes a single repository from an installation. | ||
// | ||
// GitHub docs: https://developer.github.com/v3/apps/installations/#remove-repository-from-installation | ||
func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int) (*Response, error) { | ||
u := fmt.Sprintf("/apps/installations/%v/repositories/%v", instID, repoID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, please remove the first slash in the URL. You'll notice all other endpoints don't include it either. |
||
req, err := s.client.NewRequest("DELETE", u, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return s.client.Do(ctx, req, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to not include the starting slash in the URLs, otherwise enterprise GH URLs will not work.
This should be: