MCPcopy Index your code
hub / github.com/git-bug/git-bug / createRepository

Function createRepository

bridge/github/export_test.go:302–341  ·  view source on GitHub ↗

create repository need a token with scope 'repo'

(project, token string)

Source from the content-addressed store, hash-verified

300
301// create repository need a token with scope 'repo'
302func createRepository(project, token string) error {
303 // This function use the V3 Github API because repository creation is not supported yet on the V4 API.
304 url := fmt.Sprintf("%s/user/repos", githubV3Url)
305
306 params := struct {
307 Name string `json:"name"`
308 Description string `json:"description"`
309 Private bool `json:"private"`
310 HasIssues bool `json:"has_issues"`
311 }{
312 Name: project,
313 Description: "git-bug exporter temporary test repository",
314 Private: true,
315 HasIssues: true,
316 }
317
318 data, err := json.Marshal(params)
319 if err != nil {
320 return err
321 }
322
323 req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
324 if err != nil {
325 return err
326 }
327
328 // need the token for private repositories
329 req.Header.Set("Authorization", fmt.Sprintf("token %s", token))
330
331 client := &http.Client{
332 Timeout: defaultTimeout,
333 }
334
335 resp, err := client.Do(req)
336 if err != nil {
337 return err
338 }
339
340 return resp.Body.Close()
341}
342
343// delete repository need a token with scope 'delete_repo'
344func deleteRepository(project, owner, token string) error {

Callers 1

TestGithubPushPullFunction · 0.70

Calls 2

SetMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected