@@ -111,7 +111,8 @@ def ensure_token(self, auth, name, username=None):
111111 return self .create_token (auth , name , username )
112112
113113 def create_repo (self , auth , name , description = None , private = False , auto_init = False ,
114- gitignore_templates = None , license_template = None , readme_template = None ):
114+ gitignore_templates = None , license_template = None , readme_template = None ,
115+ organization = None ):
115116 """
116117 Creates a new repository, and returns the created repository.
117118
@@ -123,6 +124,7 @@ def create_repo(self, auth, name, description=None, private=False, auto_init=Fal
123124 :param list[str] gitignore_templates: collection of ``.gitignore`` templates to apply
124125 :param str license_template: license template to apply
125126 :param str readme_template: README template to apply
127+ :param str organization: organization under which repository is created
126128 :return: a representation of the created repository
127129 :rtype: GogsRepo
128130 :raises NetworkFailure: if there is an error communicating with the server
@@ -140,7 +142,8 @@ def create_repo(self, auth, name, description=None, private=False, auto_init=Fal
140142 "readme" : readme_template
141143 }
142144 data = {k : v for (k , v ) in data .items () if v is not None }
143- response = self ._post ("/user/repos" , auth = auth , data = data )
145+ url = "/org/{0}/repos" .format (organization ) if organization else "/user/repos"
146+ response = self ._post (url , auth = auth , data = data )
144147 return GogsRepo .from_json (self ._check_ok (response ).json ())
145148
146149 def repo_exists (self , auth , username , repo_name ):
0 commit comments