Skip to content
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

Add support for forking to an organization #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions libsaas/services/github/forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ def update(self, *args, **kwargs):
raise base.MethodNotSupported()

@base.apimethod
def create(self):
def create(self, organization=None):
"""
Fork this repo.

:var organization: Specify the organization you would
like to fork to. If left as `None` repo will fork
to current user.
:vartype organization: str
"""
request = http.Request('POST', self.get_url())
params = base.get_params(('organization',), locals())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use get_params(None, locals()) to make it simpler and more consistent with other methods like this one.

request = http.Request('POST', self.get_url(), params)

return request, parsers.parse_json

Expand Down
3 changes: 3 additions & 0 deletions test/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ def test_forks(self):
self.service.repo('myuser', 'myrepo').forks().create()
self.expect('POST', '/repos/myuser/myrepo/forks')

self.service.repo('myuser', 'myrepo').forks().create(organization='myorg')
self.expect('POST', '/repos/myuser/myrepo/forks', json.dumps({'organization': 'myorg'}))

def test_users(self):
self.service.user().get()
self.expect('GET', '/user')
Expand Down