Add CreateRepoOption alias to fix #182 (#184)

This commit is contained in:
Lunny Xiao 2019-08-02 15:44:35 +00:00 committed by Gitea
parent 15a0b727a9
commit bbad0d915e
2 changed files with 6 additions and 5 deletions

View file

@ -8,12 +8,10 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"code.gitea.io/gitea/modules/structs"
) )
// AdminCreateRepo create a repo // AdminCreateRepo create a repo
func (c *Client) AdminCreateRepo(user string, opt structs.CreateRepoOption) (*Repository, error) { func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, error) {
body, err := json.Marshal(&opt) body, err := json.Marshal(&opt)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -15,6 +15,9 @@ import (
// Repository is equal to structs.Repository // Repository is equal to structs.Repository
type Repository = structs.Repository type Repository = structs.Repository
// CreateRepoOption is equal to structs.CreateRepoOption
type CreateRepoOption = structs.CreateRepoOption
// ListMyRepos lists all repositories for the authenticated user that has access to. // ListMyRepos lists all repositories for the authenticated user that has access to.
func (c *Client) ListMyRepos() ([]*Repository, error) { func (c *Client) ListMyRepos() ([]*Repository, error) {
repos := make([]*Repository, 0, 10) repos := make([]*Repository, 0, 10)
@ -34,7 +37,7 @@ func (c *Client) ListOrgRepos(org string) ([]*Repository, error) {
} }
// CreateRepo creates a repository for authenticated user. // CreateRepo creates a repository for authenticated user.
func (c *Client) CreateRepo(opt structs.CreateRepoOption) (*Repository, error) { func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, error) {
body, err := json.Marshal(&opt) body, err := json.Marshal(&opt)
if err != nil { if err != nil {
return nil, err return nil, err
@ -44,7 +47,7 @@ func (c *Client) CreateRepo(opt structs.CreateRepoOption) (*Repository, error) {
} }
// CreateOrgRepo creates an organization repository for authenticated user. // CreateOrgRepo creates an organization repository for authenticated user.
func (c *Client) CreateOrgRepo(org string, opt structs.CreateRepoOption) (*Repository, error) { func (c *Client) CreateOrgRepo(org string, opt CreateRepoOption) (*Repository, error) {
body, err := json.Marshal(&opt) body, err := json.Marshal(&opt)
if err != nil { if err != nil {
return nil, err return nil, err