MCPcopy
hub / github.com/mislav/hub / CreateRepository

Method CreateRepository

github/client.go:223–249  ·  view source on GitHub ↗
(project *Project, description, homepage string, isPrivate bool)

Source from the content-addressed store, hash-verified

221}
222
223func (client *Client) CreateRepository(project *Project, description, homepage string, isPrivate bool) (repo *Repository, err error) {
224 repoURL := "user/repos"
225 if project.Owner != client.Host.User {
226 repoURL = fmt.Sprintf("orgs/%s/repos", project.Owner)
227 }
228
229 params := map[string]interface{}{
230 "name": project.Name,
231 "description": description,
232 "homepage": homepage,
233 "private": isPrivate,
234 }
235
236 api, err := client.simpleApi()
237 if err != nil {
238 return
239 }
240
241 res, err := api.PostJSON(repoURL, params)
242 if err = checkStatus(201, "creating repository", res, err); err != nil {
243 return
244 }
245
246 repo = &Repository{}
247 err = res.Unmarshal(repo)
248 return
249}
250
251func (client *Client) DeleteRepository(project *Project) error {
252 api, err := client.simpleApi()

Callers 1

createFunction · 0.95

Calls 4

simpleApiMethod · 0.95
checkStatusFunction · 0.85
PostJSONMethod · 0.80
UnmarshalMethod · 0.80

Tested by

no test coverage detected