@@ -111,7 +111,8 @@ def ensure_token(self, auth, name, username=None):
111
111
return self .create_token (auth , name , username )
112
112
113
113
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 ):
115
116
"""
116
117
Creates a new repository, and returns the created repository.
117
118
@@ -123,6 +124,7 @@ def create_repo(self, auth, name, description=None, private=False, auto_init=Fal
123
124
:param list[str] gitignore_templates: collection of ``.gitignore`` templates to apply
124
125
:param str license_template: license template to apply
125
126
:param str readme_template: README template to apply
127
+ :param str organization: organization under which repository is created
126
128
:return: a representation of the created repository
127
129
:rtype: GogsRepo
128
130
: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
140
142
"readme" : readme_template
141
143
}
142
144
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 )
144
147
return GogsRepo .from_json (self ._check_ok (response ).json ())
145
148
146
149
def repo_exists (self , auth , username , repo_name ):
0 commit comments