Skip to content

Create new repo under certain organization #6

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

Merged
merged 2 commits into from
Mar 30, 2017
Merged
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
7 changes: 5 additions & 2 deletions gogs_client/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def ensure_token(self, auth, name, username=None):
return self.create_token(auth, name, username)

def create_repo(self, auth, name, description=None, private=False, auto_init=False,
gitignore_templates=None, license_template=None, readme_template=None):
gitignore_templates=None, license_template=None, readme_template=None,
organization=None):
"""
Creates a new repository, and returns the created repository.

Expand All @@ -123,6 +124,7 @@ def create_repo(self, auth, name, description=None, private=False, auto_init=Fal
:param list[str] gitignore_templates: collection of ``.gitignore`` templates to apply
:param str license_template: license template to apply
:param str readme_template: README template to apply
:param str organization: organization under which repository is created
:return: a representation of the created repository
:rtype: GogsRepo
:raises NetworkFailure: if there is an error communicating with the server
Expand All @@ -140,7 +142,8 @@ def create_repo(self, auth, name, description=None, private=False, auto_init=Fal
"readme": readme_template
}
data = {k: v for (k, v) in data.items() if v is not None}
response = self._post("/user/repos", auth=auth, data=data)
url = "/org/{0}/repos".format(organization) if organization else "/user/repos"
response = self._post(url, auth=auth, data=data)
return GogsRepo.from_json(self._check_ok(response).json())

def repo_exists(self, auth, username, repo_name):
Expand Down