From ee6b9a279b2fe47ff984c9d8ae09904864965ff2 Mon Sep 17 00:00:00 2001 From: Ruben Vermeersch Date: Wed, 28 Oct 2015 17:04:48 +0100 Subject: [PATCH 1/2] Add binding for POST /repos/migrate --- repo.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/repo.go b/repo.go index 83de2de..315c6aa 100644 --- a/repo.go +++ b/repo.go @@ -82,3 +82,29 @@ func (c *Client) DeleteRepo(owner, repo string) error { _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s", owner, repo), nil, nil) return err } + +type MigrateRepoOption struct { + CloneAddr string `json:"clone_addr" binding:"Required"` + AuthUsername string `json:"auth_username"` + AuthPassword string `json:"auth_password"` + Uid int `json:"uid" binding:"Required"` + RepoName string `json:"repo_name" binding:"Required"` + Mirror bool `json:"mirror"` + Private bool `json:"private"` + Description string `json:"description"` +} + +// MigrateRepo migrates a repository from other Git hosting sources for the +// authenticated user. +// +// To migrate a repository for a organization, the authenticated user must be a +// owner of the specified organization. +func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, error) { + body, err := json.Marshal(&opt) + if err != nil { + return nil, err + } + repo := new(Repository) + return repo, c.getParsedResponse("POST", "/repos/migrate", + http.Header{"content-type": []string{"application/json"}}, bytes.NewReader(body), repo) +} From a022a5cc719783c094c1d6364a5f0c59c5ad5f44 Mon Sep 17 00:00:00 2001 From: Ruben Vermeersch Date: Thu, 29 Oct 2015 08:32:08 +0100 Subject: [PATCH 2/2] Rename Uid -> UID --- repo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo.go b/repo.go index 315c6aa..b79ea22 100644 --- a/repo.go +++ b/repo.go @@ -87,7 +87,7 @@ type MigrateRepoOption struct { CloneAddr string `json:"clone_addr" binding:"Required"` AuthUsername string `json:"auth_username"` AuthPassword string `json:"auth_password"` - Uid int `json:"uid" binding:"Required"` + UID int `json:"uid" binding:"Required"` RepoName string `json:"repo_name" binding:"Required"` Mirror bool `json:"mirror"` Private bool `json:"private"`