mirror of
				https://gitea.com/gitea/tea.git
				synced 2025-10-31 01:05:26 +01:00 
			
		
		
		
	Update gitea go-sdk to v0.15.0 (#385)
Update "code.gitea.io/sdk/gitea" to latest release Reviewed-on: https://gitea.com/gitea/tea/pulls/385 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-committed-by: 6543 <6543@obermui.de>
This commit is contained in:
		
							
								
								
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/admin_cron.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/admin_cron.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -39,6 +39,9 @@ func (c *Client) RunCronTasks(task string) (*Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&task); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("POST", fmt.Sprintf("/admin/cron/%s", task), jsonHeader, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/admin_org.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/admin_org.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -26,6 +26,9 @@ func (c *Client) AdminListOrgs(opt AdminListOrgsOptions) ([]*Organization, *Resp | ||||
|  | ||||
| // AdminCreateOrg create an organization | ||||
| func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/admin_repo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/admin_repo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -12,6 +12,9 @@ import ( | ||||
|  | ||||
| // AdminCreateRepo create a repo | ||||
| func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
|   | ||||
							
								
								
									
										62
									
								
								vendor/code.gitea.io/sdk/gitea/admin_user.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										62
									
								
								vendor/code.gitea.io/sdk/gitea/admin_user.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -26,14 +26,15 @@ func (c *Client) AdminListUsers(opt AdminListUsersOptions) ([]*User, *Response, | ||||
|  | ||||
| // CreateUserOption create user options | ||||
| type CreateUserOption struct { | ||||
| 	SourceID           int64  `json:"source_id"` | ||||
| 	LoginName          string `json:"login_name"` | ||||
| 	Username           string `json:"username"` | ||||
| 	FullName           string `json:"full_name"` | ||||
| 	Email              string `json:"email"` | ||||
| 	Password           string `json:"password"` | ||||
| 	MustChangePassword *bool  `json:"must_change_password"` | ||||
| 	SendNotify         bool   `json:"send_notify"` | ||||
| 	SourceID           int64        `json:"source_id"` | ||||
| 	LoginName          string       `json:"login_name"` | ||||
| 	Username           string       `json:"username"` | ||||
| 	FullName           string       `json:"full_name"` | ||||
| 	Email              string       `json:"email"` | ||||
| 	Password           string       `json:"password"` | ||||
| 	MustChangePassword *bool        `json:"must_change_password"` | ||||
| 	SendNotify         bool         `json:"send_notify"` | ||||
| 	Visibility         *VisibleType `json:"visibility"` | ||||
| } | ||||
|  | ||||
| // Validate the CreateUserOption struct | ||||
| @@ -63,25 +64,31 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, *Response, error) | ||||
|  | ||||
| // EditUserOption edit user options | ||||
| type EditUserOption struct { | ||||
| 	SourceID                int64   `json:"source_id"` | ||||
| 	LoginName               string  `json:"login_name"` | ||||
| 	Email                   *string `json:"email"` | ||||
| 	FullName                *string `json:"full_name"` | ||||
| 	Password                string  `json:"password"` | ||||
| 	MustChangePassword      *bool   `json:"must_change_password"` | ||||
| 	Website                 *string `json:"website"` | ||||
| 	Location                *string `json:"location"` | ||||
| 	Active                  *bool   `json:"active"` | ||||
| 	Admin                   *bool   `json:"admin"` | ||||
| 	AllowGitHook            *bool   `json:"allow_git_hook"` | ||||
| 	AllowImportLocal        *bool   `json:"allow_import_local"` | ||||
| 	MaxRepoCreation         *int    `json:"max_repo_creation"` | ||||
| 	ProhibitLogin           *bool   `json:"prohibit_login"` | ||||
| 	AllowCreateOrganization *bool   `json:"allow_create_organization"` | ||||
| 	SourceID                int64        `json:"source_id"` | ||||
| 	LoginName               string       `json:"login_name"` | ||||
| 	Email                   *string      `json:"email"` | ||||
| 	FullName                *string      `json:"full_name"` | ||||
| 	Password                string       `json:"password"` | ||||
| 	Description             *string      `json:"description"` | ||||
| 	MustChangePassword      *bool        `json:"must_change_password"` | ||||
| 	Website                 *string      `json:"website"` | ||||
| 	Location                *string      `json:"location"` | ||||
| 	Active                  *bool        `json:"active"` | ||||
| 	Admin                   *bool        `json:"admin"` | ||||
| 	AllowGitHook            *bool        `json:"allow_git_hook"` | ||||
| 	AllowImportLocal        *bool        `json:"allow_import_local"` | ||||
| 	MaxRepoCreation         *int         `json:"max_repo_creation"` | ||||
| 	ProhibitLogin           *bool        `json:"prohibit_login"` | ||||
| 	AllowCreateOrganization *bool        `json:"allow_create_organization"` | ||||
| 	Restricted              *bool        `json:"restricted"` | ||||
| 	Visibility              *VisibleType `json:"visibility"` | ||||
| } | ||||
|  | ||||
| // AdminEditUser modify user informations | ||||
| func (c *Client) AdminEditUser(user string, opt EditUserOption) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -92,12 +99,18 @@ func (c *Client) AdminEditUser(user string, opt EditUserOption) (*Response, erro | ||||
|  | ||||
| // AdminDeleteUser delete one user according name | ||||
| func (c *Client) AdminDeleteUser(user string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/admin/users/%s", user), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // AdminCreateUserPublicKey adds a public key for the user | ||||
| func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| @@ -109,6 +122,9 @@ func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*Pu | ||||
|  | ||||
| // AdminDeleteUserPublicKey deletes a user's public key | ||||
| func (c *Client) AdminDeleteUserPublicKey(user string, keyID int) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/admin/users/%s/keys/%d", user, keyID), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/attachment.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/attachment.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -31,6 +31,9 @@ type ListReleaseAttachmentsOptions struct { | ||||
|  | ||||
| // ListReleaseAttachments list release's attachments | ||||
| func (c *Client) ListReleaseAttachments(user, repo string, release int64, opt ListReleaseAttachmentsOptions) ([]*Attachment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	attachments := make([]*Attachment, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", | ||||
| @@ -41,6 +44,9 @@ func (c *Client) ListReleaseAttachments(user, repo string, release int64, opt Li | ||||
|  | ||||
| // GetReleaseAttachment returns the requested attachment | ||||
| func (c *Client) GetReleaseAttachment(user, repo string, release int64, id int64) (*Attachment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	a := new(Attachment) | ||||
| 	resp, err := c.getParsedResponse("GET", | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, id), | ||||
| @@ -50,6 +56,9 @@ func (c *Client) GetReleaseAttachment(user, repo string, release int64, id int64 | ||||
|  | ||||
| // CreateReleaseAttachment creates an attachment for the given release | ||||
| func (c *Client) CreateReleaseAttachment(user, repo string, release int64, file io.Reader, filename string) (*Attachment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	// Write file to body | ||||
| 	body := new(bytes.Buffer) | ||||
| 	writer := multipart.NewWriter(body) | ||||
| @@ -80,6 +89,9 @@ type EditAttachmentOptions struct { | ||||
|  | ||||
| // EditReleaseAttachment updates the given attachment with the given options | ||||
| func (c *Client) EditReleaseAttachment(user, repo string, release int64, attachment int64, form EditAttachmentOptions) (*Attachment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&form) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| @@ -91,6 +103,9 @@ func (c *Client) EditReleaseAttachment(user, repo string, release int64, attachm | ||||
|  | ||||
| // DeleteReleaseAttachment deletes the given attachment including the uploaded file | ||||
| func (c *Client) DeleteReleaseAttachment(user, repo string, release int64, id int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, id), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										22
									
								
								vendor/code.gitea.io/sdk/gitea/client.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								vendor/code.gitea.io/sdk/gitea/client.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -13,6 +13,7 @@ import ( | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"net/http" | ||||
| 	"net/url" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
|  | ||||
| @@ -309,3 +310,24 @@ func (c *Client) getStatusCode(method, path string, header http.Header, body io. | ||||
|  | ||||
| 	return resp.StatusCode, resp, nil | ||||
| } | ||||
|  | ||||
| // pathEscapeSegments escapes segments of a path while not escaping forward slash | ||||
| func pathEscapeSegments(path string) string { | ||||
| 	slice := strings.Split(path, "/") | ||||
| 	for index := range slice { | ||||
| 		slice[index] = url.PathEscape(slice[index]) | ||||
| 	} | ||||
| 	escapedPath := strings.Join(slice, "/") | ||||
| 	return escapedPath | ||||
| } | ||||
|  | ||||
| // escapeValidatePathSegments is a help function to validate and encode url path segments | ||||
| func escapeValidatePathSegments(seg ...*string) error { | ||||
| 	for i := range seg { | ||||
| 		if seg[i] == nil || len(*seg[i]) == 0 { | ||||
| 			return fmt.Errorf("path segment [%d] is empty", i) | ||||
| 		} | ||||
| 		*seg[i] = url.PathEscape(*seg[i]) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/code.gitea.io/sdk/gitea/fork.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/code.gitea.io/sdk/gitea/fork.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -17,6 +17,9 @@ type ListForksOptions struct { | ||||
|  | ||||
| // ListForks list a repository's forks | ||||
| func (c *Client) ListForks(user string, repo string, opt ListForksOptions) ([]*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	forks := make([]*Repository, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", | ||||
| @@ -33,6 +36,9 @@ type CreateForkOption struct { | ||||
|  | ||||
| // CreateFork create a fork of a repository | ||||
| func (c *Client) CreateFork(user, repo string, form CreateForkOption) (*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(form) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/git_blob.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/git_blob.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,6 +19,9 @@ type GitBlobResponse struct { | ||||
|  | ||||
| // GetBlob get the blob of a repository file | ||||
| func (c *Client) GetBlob(user, repo, sha string) (*GitBlobResponse, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &sha); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	blob := new(GitBlobResponse) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/blobs/%s", user, repo, sha), nil, nil, blob) | ||||
| 	return blob, resp, err | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/code.gitea.io/sdk/gitea/git_hook.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/code.gitea.io/sdk/gitea/git_hook.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -24,6 +24,9 @@ type ListRepoGitHooksOptions struct { | ||||
|  | ||||
| // ListRepoGitHooks list all the Git hooks of one repository | ||||
| func (c *Client) ListRepoGitHooks(user, repo string, opt ListRepoGitHooksOptions) ([]*GitHook, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	hooks := make([]*GitHook, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &hooks) | ||||
| @@ -32,6 +35,9 @@ func (c *Client) ListRepoGitHooks(user, repo string, opt ListRepoGitHooksOptions | ||||
|  | ||||
| // GetRepoGitHook get a Git hook of a repository | ||||
| func (c *Client) GetRepoGitHook(user, repo, id string) (*GitHook, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &id); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	h := new(GitHook) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), nil, nil, h) | ||||
| 	return h, resp, err | ||||
| @@ -44,6 +50,9 @@ type EditGitHookOption struct { | ||||
|  | ||||
| // EditRepoGitHook modify one Git hook of a repository | ||||
| func (c *Client) EditRepoGitHook(user, repo, id string, opt EditGitHookOption) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &id); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -54,6 +63,9 @@ func (c *Client) EditRepoGitHook(user, repo, id string, opt EditGitHookOption) ( | ||||
|  | ||||
| // DeleteRepoGitHook delete one Git hook from a repository | ||||
| func (c *Client) DeleteRepoGitHook(user, repo, id string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &id); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										1
									
								
								vendor/code.gitea.io/sdk/gitea/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/code.gitea.io/sdk/gitea/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -3,6 +3,7 @@ module code.gitea.io/sdk/gitea | ||||
| go 1.13 | ||||
|  | ||||
| require ( | ||||
| 	code.gitea.io/gitea-vet v0.2.1 // indirect | ||||
| 	github.com/hashicorp/go-version v1.2.1 | ||||
| 	github.com/stretchr/testify v1.4.0 | ||||
| ) | ||||
|   | ||||
							
								
								
									
										22
									
								
								vendor/code.gitea.io/sdk/gitea/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								vendor/code.gitea.io/sdk/gitea/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,7 +1,7 @@ | ||||
| code.gitea.io/gitea-vet v0.2.1 h1:b30by7+3SkmiftK0RjuXqFvZg2q4p68uoPGuxhzBN0s= | ||||
| code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE= | ||||
| github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= | ||||
| github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= | ||||
| github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= | ||||
| github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| @@ -9,6 +9,24 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= | ||||
| github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||||
| github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||
| golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||||
| golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||||
| golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224 h1:azwY/v0y0K4mFHVsg5+UrTgchqALYWpqVo6vL5OmkmI= | ||||
| golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= | ||||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||||
|   | ||||
							
								
								
									
										54
									
								
								vendor/code.gitea.io/sdk/gitea/hook.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										54
									
								
								vendor/code.gitea.io/sdk/gitea/hook.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -24,6 +24,28 @@ type Hook struct { | ||||
| 	Created time.Time         `json:"created_at"` | ||||
| } | ||||
|  | ||||
| // HookType represent all webhook types gitea currently offer | ||||
| type HookType string | ||||
|  | ||||
| const ( | ||||
| 	// HookTypeDingtalk webhook that dingtalk understand | ||||
| 	HookTypeDingtalk HookType = "dingtalk" | ||||
| 	// HookTypeDiscord webhook that discord understand | ||||
| 	HookTypeDiscord HookType = "discord" | ||||
| 	// HookTypeGitea webhook that gitea understand | ||||
| 	HookTypeGitea HookType = "gitea" | ||||
| 	// HookTypeGogs webhook that gogs understand | ||||
| 	HookTypeGogs HookType = "gogs" | ||||
| 	// HookTypeMsteams webhook that msteams understand | ||||
| 	HookTypeMsteams HookType = "msteams" | ||||
| 	// HookTypeSlack webhook that slack understand | ||||
| 	HookTypeSlack HookType = "slack" | ||||
| 	// HookTypeTelegram webhook that telegram understand | ||||
| 	HookTypeTelegram HookType = "telegram" | ||||
| 	// HookTypeFeishu webhook that feishu understand | ||||
| 	HookTypeFeishu HookType = "feishu" | ||||
| ) | ||||
|  | ||||
| // ListHooksOptions options for listing hooks | ||||
| type ListHooksOptions struct { | ||||
| 	ListOptions | ||||
| @@ -31,6 +53,9 @@ type ListHooksOptions struct { | ||||
|  | ||||
| // ListOrgHooks list all the hooks of one organization | ||||
| func (c *Client) ListOrgHooks(org string, opt ListHooksOptions) ([]*Hook, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	hooks := make([]*Hook, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks?%s", org, opt.getURLQuery().Encode()), nil, nil, &hooks) | ||||
| @@ -39,6 +64,9 @@ func (c *Client) ListOrgHooks(org string, opt ListHooksOptions) ([]*Hook, *Respo | ||||
|  | ||||
| // ListRepoHooks list all the hooks of one repository | ||||
| func (c *Client) ListRepoHooks(user, repo string, opt ListHooksOptions) ([]*Hook, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	hooks := make([]*Hook, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &hooks) | ||||
| @@ -47,6 +75,9 @@ func (c *Client) ListRepoHooks(user, repo string, opt ListHooksOptions) ([]*Hook | ||||
|  | ||||
| // GetOrgHook get a hook of an organization | ||||
| func (c *Client) GetOrgHook(org string, id int64) (*Hook, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	h := new(Hook) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), nil, nil, h) | ||||
| 	return h, resp, err | ||||
| @@ -54,6 +85,9 @@ func (c *Client) GetOrgHook(org string, id int64) (*Hook, *Response, error) { | ||||
|  | ||||
| // GetRepoHook get a hook of a repository | ||||
| func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	h := new(Hook) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil, h) | ||||
| 	return h, resp, err | ||||
| @@ -61,7 +95,7 @@ func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, *Response, err | ||||
|  | ||||
| // CreateHookOption options when create a hook | ||||
| type CreateHookOption struct { | ||||
| 	Type         string            `json:"type"` | ||||
| 	Type         HookType          `json:"type"` | ||||
| 	Config       map[string]string `json:"config"` | ||||
| 	Events       []string          `json:"events"` | ||||
| 	BranchFilter string            `json:"branch_filter"` | ||||
| @@ -78,6 +112,9 @@ func (opt CreateHookOption) Validate() error { | ||||
|  | ||||
| // CreateOrgHook create one hook for an organization, with options | ||||
| func (c *Client) CreateOrgHook(org string, opt CreateHookOption) (*Hook, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -92,6 +129,9 @@ func (c *Client) CreateOrgHook(org string, opt CreateHookOption) (*Hook, *Respon | ||||
|  | ||||
| // CreateRepoHook create one hook for a repository, with options | ||||
| func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| @@ -111,6 +151,9 @@ type EditHookOption struct { | ||||
|  | ||||
| // EditOrgHook modify one hook of an organization, with hook id and options | ||||
| func (c *Client) EditOrgHook(org string, id int64, opt EditHookOption) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -121,6 +164,9 @@ func (c *Client) EditOrgHook(org string, id int64, opt EditHookOption) (*Respons | ||||
|  | ||||
| // EditRepoHook modify one hook of a repository, with hook id and options | ||||
| func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -131,12 +177,18 @@ func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) ( | ||||
|  | ||||
| // DeleteOrgHook delete one hook from an organization, with hook id | ||||
| func (c *Client) DeleteOrgHook(org string, id int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // DeleteRepoHook delete one hook from a repository, with hook id | ||||
| func (c *Client) DeleteRepoHook(user, repo string, id int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										60
									
								
								vendor/code.gitea.io/sdk/gitea/issue.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										60
									
								
								vendor/code.gitea.io/sdk/gitea/issue.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -42,10 +42,7 @@ type Issue struct { | ||||
| 	Ref              string     `json:"ref"` | ||||
| 	Labels           []*Label   `json:"labels"` | ||||
| 	Milestone        *Milestone `json:"milestone"` | ||||
| 	// deprecated | ||||
| 	// TODO: rm on sdk 0.15.0 | ||||
| 	Assignee  *User   `json:"assignee"` | ||||
| 	Assignees []*User `json:"assignees"` | ||||
| 	Assignees        []*User    `json:"assignees"` | ||||
| 	// Whether the issue is open or closed | ||||
| 	State       StateType        `json:"state"` | ||||
| 	IsLocked    bool             `json:"is_locked"` | ||||
| @@ -66,6 +63,14 @@ type ListIssueOption struct { | ||||
| 	Labels     []string | ||||
| 	Milestones []string | ||||
| 	KeyWord    string | ||||
| 	Since      time.Time | ||||
| 	Before     time.Time | ||||
| 	// filter by created by username | ||||
| 	CreatedBy string | ||||
| 	// filter by assigned to username | ||||
| 	AssignedBy string | ||||
| 	// filter by username mentioned | ||||
| 	MentionedBy string | ||||
| } | ||||
|  | ||||
| // StateType issue state type | ||||
| @@ -114,6 +119,23 @@ func (opt *ListIssueOption) QueryEncode() string { | ||||
| 		query.Add("milestones", strings.Join(opt.Milestones, ",")) | ||||
| 	} | ||||
|  | ||||
| 	if !opt.Since.IsZero() { | ||||
| 		query.Add("since", opt.Since.Format(time.RFC3339)) | ||||
| 	} | ||||
| 	if !opt.Before.IsZero() { | ||||
| 		query.Add("before", opt.Before.Format(time.RFC3339)) | ||||
| 	} | ||||
|  | ||||
| 	if len(opt.CreatedBy) > 0 { | ||||
| 		query.Add("created_by", opt.CreatedBy) | ||||
| 	} | ||||
| 	if len(opt.AssignedBy) > 0 { | ||||
| 		query.Add("assigned_by", opt.AssignedBy) | ||||
| 	} | ||||
| 	if len(opt.MentionedBy) > 0 { | ||||
| 		query.Add("mentioned_by", opt.MentionedBy) | ||||
| 	} | ||||
|  | ||||
| 	return query.Encode() | ||||
| } | ||||
|  | ||||
| @@ -140,6 +162,9 @@ func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, *Response, error) { | ||||
|  | ||||
| // ListRepoIssues returns all issues for a given repository | ||||
| func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Issue, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	issues := make([]*Issue, 0, opt.PageSize) | ||||
|  | ||||
| @@ -161,6 +186,9 @@ func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Iss | ||||
|  | ||||
| // GetIssue returns a single issue for a given repository | ||||
| func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	issue := new(Issue) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), nil, nil, issue) | ||||
| 	if e := c.checkServerVersionGreaterThanOrEqual(version1_12_0); e != nil && issue.Repository != nil { | ||||
| @@ -172,12 +200,9 @@ func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, *Response, e | ||||
|  | ||||
| // CreateIssueOption options to create one issue | ||||
| type CreateIssueOption struct { | ||||
| 	Title string `json:"title"` | ||||
| 	Body  string `json:"body"` | ||||
| 	Ref   string `json:"ref"` | ||||
| 	// deprecated | ||||
| 	// TODO: rm on sdk 0.15.0 | ||||
| 	Assignee  string     `json:"assignee"` | ||||
| 	Title     string     `json:"title"` | ||||
| 	Body      string     `json:"body"` | ||||
| 	Ref       string     `json:"ref"` | ||||
| 	Assignees []string   `json:"assignees"` | ||||
| 	Deadline  *time.Time `json:"due_date"` | ||||
| 	// milestone id | ||||
| @@ -197,6 +222,9 @@ func (opt CreateIssueOption) Validate() error { | ||||
|  | ||||
| // CreateIssue create a new issue for a given repository | ||||
| func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -213,12 +241,9 @@ func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, | ||||
|  | ||||
| // EditIssueOption options for editing an issue | ||||
| type EditIssueOption struct { | ||||
| 	Title string  `json:"title"` | ||||
| 	Body  *string `json:"body"` | ||||
| 	Ref   *string `json:"ref"` | ||||
| 	// deprecated | ||||
| 	// TODO: rm on sdk 0.15.0 | ||||
| 	Assignee       *string    `json:"assignee"` | ||||
| 	Title          string     `json:"title"` | ||||
| 	Body           *string    `json:"body"` | ||||
| 	Ref            *string    `json:"ref"` | ||||
| 	Assignees      []string   `json:"assignees"` | ||||
| 	Milestone      *int64     `json:"milestone"` | ||||
| 	State          *StateType `json:"state"` | ||||
| @@ -236,6 +261,9 @@ func (opt EditIssueOption) Validate() error { | ||||
|  | ||||
| // EditIssue modify an existing issue for a given repository | ||||
| func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption) (*Issue, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										18
									
								
								vendor/code.gitea.io/sdk/gitea/issue_comment.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								vendor/code.gitea.io/sdk/gitea/issue_comment.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -47,6 +47,9 @@ func (opt *ListIssueCommentOptions) QueryEncode() string { | ||||
|  | ||||
| // ListIssueComments list comments on an issue. | ||||
| func (c *Client) ListIssueComments(owner, repo string, index int64, opt ListIssueCommentOptions) ([]*Comment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index)) | ||||
| 	link.RawQuery = opt.QueryEncode() | ||||
| @@ -57,6 +60,9 @@ func (c *Client) ListIssueComments(owner, repo string, index int64, opt ListIssu | ||||
|  | ||||
| // ListRepoIssueComments list comments for a given repo. | ||||
| func (c *Client) ListRepoIssueComments(owner, repo string, opt ListIssueCommentOptions) ([]*Comment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo)) | ||||
| 	link.RawQuery = opt.QueryEncode() | ||||
| @@ -67,6 +73,9 @@ func (c *Client) ListRepoIssueComments(owner, repo string, opt ListIssueCommentO | ||||
|  | ||||
| // GetIssueComment get a comment for a given repo by id. | ||||
| func (c *Client) GetIssueComment(owner, repo string, id int64) (*Comment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	comment := new(Comment) | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return comment, nil, err | ||||
| @@ -90,6 +99,9 @@ func (opt CreateIssueCommentOption) Validate() error { | ||||
|  | ||||
| // CreateIssueComment create comment on an issue. | ||||
| func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateIssueCommentOption) (*Comment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -117,6 +129,9 @@ func (opt EditIssueCommentOption) Validate() error { | ||||
|  | ||||
| // EditIssueComment edits an issue comment. | ||||
| func (c *Client) EditIssueComment(owner, repo string, commentID int64, opt EditIssueCommentOption) (*Comment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -131,6 +146,9 @@ func (c *Client) EditIssueComment(owner, repo string, commentID int64, opt EditI | ||||
|  | ||||
| // DeleteIssueComment deletes an issue comment. | ||||
| func (c *Client) DeleteIssueComment(owner, repo string, commentID int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/comments/%d", owner, repo, commentID), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										30
									
								
								vendor/code.gitea.io/sdk/gitea/issue_label.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										30
									
								
								vendor/code.gitea.io/sdk/gitea/issue_label.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,6 +29,9 @@ type ListLabelsOptions struct { | ||||
|  | ||||
| // ListRepoLabels list labels of one repository | ||||
| func (c *Client) ListRepoLabels(owner, repo string, opt ListLabelsOptions) ([]*Label, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	labels := make([]*Label, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels?%s", owner, repo, opt.getURLQuery().Encode()), nil, nil, &labels) | ||||
| @@ -37,6 +40,9 @@ func (c *Client) ListRepoLabels(owner, repo string, opt ListLabelsOptions) ([]*L | ||||
|  | ||||
| // GetRepoLabel get one label of repository by repo it | ||||
| func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	label := new(Label) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label) | ||||
| 	return label, resp, err | ||||
| @@ -67,6 +73,9 @@ func (opt CreateLabelOption) Validate() error { | ||||
|  | ||||
| // CreateLabel create one label of repository | ||||
| func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -114,6 +123,9 @@ func (opt EditLabelOption) Validate() error { | ||||
|  | ||||
| // EditLabel modify one label with options | ||||
| func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (*Label, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -128,12 +140,18 @@ func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (* | ||||
|  | ||||
| // DeleteLabel delete one label of repository by id | ||||
| func (c *Client) DeleteLabel(owner, repo string, id int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // GetIssueLabels get labels of one issue via issue id | ||||
| func (c *Client) GetIssueLabels(owner, repo string, index int64, opts ListLabelsOptions) ([]*Label, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	labels := make([]*Label, 0, 5) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels?%s", owner, repo, index, opts.getURLQuery().Encode()), nil, nil, &labels) | ||||
| 	return labels, resp, err | ||||
| @@ -147,6 +165,9 @@ type IssueLabelsOption struct { | ||||
|  | ||||
| // AddIssueLabels add one or more labels to one issue | ||||
| func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| @@ -158,6 +179,9 @@ func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabels | ||||
|  | ||||
| // ReplaceIssueLabels replace old labels of issue with new labels | ||||
| func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| @@ -170,12 +194,18 @@ func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt IssueLa | ||||
| // DeleteIssueLabel delete one label of one issue by issue id and label id | ||||
| // TODO: maybe we need delete by label name and issue id | ||||
| func (c *Client) DeleteIssueLabel(owner, repo string, index, label int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels/%d", owner, repo, index, label), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // ClearIssueLabels delete all the labels of one issue. | ||||
| func (c *Client) ClearIssueLabels(owner, repo string, index int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										24
									
								
								vendor/code.gitea.io/sdk/gitea/issue_milestone.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								vendor/code.gitea.io/sdk/gitea/issue_milestone.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -49,6 +49,9 @@ func (opt *ListMilestoneOption) QueryEncode() string { | ||||
|  | ||||
| // ListRepoMilestones list all the milestones of one repository | ||||
| func (c *Client) ListRepoMilestones(owner, repo string, opt ListMilestoneOption) ([]*Milestone, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	milestones := make([]*Milestone, 0, opt.PageSize) | ||||
|  | ||||
| @@ -60,6 +63,9 @@ func (c *Client) ListRepoMilestones(owner, repo string, opt ListMilestoneOption) | ||||
|  | ||||
| // GetMilestone get one milestone by repo name and milestone id | ||||
| func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	milestone := new(Milestone) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone) | ||||
| 	return milestone, resp, err | ||||
| @@ -72,6 +78,9 @@ func (c *Client) GetMilestoneByName(owner, repo string, name string) (*Milestone | ||||
| 		m, resp, err := c.resolveMilestoneByName(owner, repo, name) | ||||
| 		return m, resp, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &name); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	milestone := new(Milestone) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%s", owner, repo, name), nil, nil, milestone) | ||||
| 	return milestone, resp, err | ||||
| @@ -95,6 +104,9 @@ func (opt CreateMilestoneOption) Validate() error { | ||||
|  | ||||
| // CreateMilestone create one milestone with options | ||||
| func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) (*Milestone, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -135,6 +147,9 @@ func (opt EditMilestoneOption) Validate() error { | ||||
|  | ||||
| // EditMilestone modify milestone with options | ||||
| func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOption) (*Milestone, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -157,6 +172,9 @@ func (c *Client) EditMilestoneByName(owner, repo string, name string, opt EditMi | ||||
| 		} | ||||
| 		return c.EditMilestone(owner, repo, m.ID, opt) | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &name); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -171,6 +189,9 @@ func (c *Client) EditMilestoneByName(owner, repo string, name string, opt EditMi | ||||
|  | ||||
| // DeleteMilestone delete one milestone by id | ||||
| func (c *Client) DeleteMilestone(owner, repo string, id int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
| @@ -185,6 +206,9 @@ func (c *Client) DeleteMilestoneByName(owner, repo string, name string) (*Respon | ||||
| 		} | ||||
| 		return c.DeleteMilestone(owner, repo, m.ID) | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &name); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/milestones/%s", owner, repo, name), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										18
									
								
								vendor/code.gitea.io/sdk/gitea/issue_reaction.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								vendor/code.gitea.io/sdk/gitea/issue_reaction.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,6 +20,9 @@ type Reaction struct { | ||||
|  | ||||
| // GetIssueReactions get a list reactions of an issue | ||||
| func (c *Client) GetIssueReactions(owner, repo string, index int64) ([]*Reaction, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	reactions := make([]*Reaction, 0, 10) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/reactions", owner, repo, index), nil, nil, &reactions) | ||||
| 	return reactions, resp, err | ||||
| @@ -27,6 +30,9 @@ func (c *Client) GetIssueReactions(owner, repo string, index int64) ([]*Reaction | ||||
|  | ||||
| // GetIssueCommentReactions get a list of reactions from a comment of an issue | ||||
| func (c *Client) GetIssueCommentReactions(owner, repo string, commentID int64) ([]*Reaction, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	reactions := make([]*Reaction, 0, 10) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments/%d/reactions", owner, repo, commentID), nil, nil, &reactions) | ||||
| 	return reactions, resp, err | ||||
| @@ -39,6 +45,9 @@ type editReactionOption struct { | ||||
|  | ||||
| // PostIssueReaction add a reaction to an issue | ||||
| func (c *Client) PostIssueReaction(owner, repo string, index int64, reaction string) (*Reaction, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	reactionResponse := new(Reaction) | ||||
| 	body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | ||||
| 	if err != nil { | ||||
| @@ -52,6 +61,9 @@ func (c *Client) PostIssueReaction(owner, repo string, index int64, reaction str | ||||
|  | ||||
| // DeleteIssueReaction remove a reaction from an issue | ||||
| func (c *Client) DeleteIssueReaction(owner, repo string, index int64, reaction string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -62,6 +74,9 @@ func (c *Client) DeleteIssueReaction(owner, repo string, index int64, reaction s | ||||
|  | ||||
| // PostIssueCommentReaction add a reaction to a comment of an issue | ||||
| func (c *Client) PostIssueCommentReaction(owner, repo string, commentID int64, reaction string) (*Reaction, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	reactionResponse := new(Reaction) | ||||
| 	body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | ||||
| 	if err != nil { | ||||
| @@ -75,6 +90,9 @@ func (c *Client) PostIssueCommentReaction(owner, repo string, commentID int64, r | ||||
|  | ||||
| // DeleteIssueCommentReaction remove a reaction from a comment of an issue | ||||
| func (c *Client) DeleteIssueCommentReaction(owner, repo string, commentID int64, reaction string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
|   | ||||
							
								
								
									
										9
									
								
								vendor/code.gitea.io/sdk/gitea/issue_stopwatch.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								vendor/code.gitea.io/sdk/gitea/issue_stopwatch.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,6 +29,9 @@ func (c *Client) GetMyStopwatches() ([]*StopWatch, *Response, error) { | ||||
|  | ||||
| // DeleteIssueStopwatch delete / cancel a specific stopwatch | ||||
| func (c *Client) DeleteIssueStopwatch(owner, repo string, index int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/stopwatch/delete", owner, repo, index), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
| @@ -36,6 +39,9 @@ func (c *Client) DeleteIssueStopwatch(owner, repo string, index int64) (*Respons | ||||
| // StartIssueStopWatch starts a stopwatch for an existing issue for a given | ||||
| // repository | ||||
| func (c *Client) StartIssueStopWatch(owner, repo string, index int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/stopwatch/start", owner, repo, index), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
| @@ -43,6 +49,9 @@ func (c *Client) StartIssueStopWatch(owner, repo string, index int64) (*Response | ||||
| // StopIssueStopWatch stops an existing stopwatch for an issue in a given | ||||
| // repository | ||||
| func (c *Client) StopIssueStopWatch(owner, repo string, index int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/stopwatch/stop", owner, repo, index), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/code.gitea.io/sdk/gitea/issue_subscription.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/code.gitea.io/sdk/gitea/issue_subscription.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -11,6 +11,9 @@ import ( | ||||
|  | ||||
| // GetIssueSubscribers get list of users who subscribed on an issue | ||||
| func (c *Client) GetIssueSubscribers(owner, repo string, index int64) ([]*User, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	subscribers := make([]*User, 0, 10) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions", owner, repo, index), nil, nil, &subscribers) | ||||
| 	return subscribers, resp, err | ||||
| @@ -18,6 +21,9 @@ func (c *Client) GetIssueSubscribers(owner, repo string, index int64) ([]*User, | ||||
|  | ||||
| // AddIssueSubscription Subscribe user to issue | ||||
| func (c *Client) AddIssueSubscription(owner, repo string, index int64, user string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &user); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	status, resp, err := c.getStatusCode("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions/%s", owner, repo, index, user), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return resp, err | ||||
| @@ -33,6 +39,9 @@ func (c *Client) AddIssueSubscription(owner, repo string, index int64, user stri | ||||
|  | ||||
| // DeleteIssueSubscription unsubscribe user from issue | ||||
| func (c *Client) DeleteIssueSubscription(owner, repo string, index int64, user string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &user); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	status, resp, err := c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions/%s", owner, repo, index, user), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return resp, err | ||||
| @@ -48,6 +57,9 @@ func (c *Client) DeleteIssueSubscription(owner, repo string, index int64, user s | ||||
|  | ||||
| // CheckIssueSubscription check if current user is subscribed to an issue | ||||
| func (c *Client) CheckIssueSubscription(owner, repo string, index int64) (*WatchInfo, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -55,6 +55,9 @@ func (opt *ListTrackedTimesOptions) QueryEncode() string { | ||||
|  | ||||
| // ListRepoTrackedTimes list tracked times of a repository | ||||
| func (c *Client) ListRepoTrackedTimes(owner, repo string, opt ListTrackedTimesOptions) ([]*TrackedTime, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/times", owner, repo)) | ||||
| 	opt.setDefaults() | ||||
| 	link.RawQuery = opt.QueryEncode() | ||||
| @@ -90,6 +93,9 @@ func (opt AddTimeOption) Validate() error { | ||||
|  | ||||
| // AddTime adds time to issue with the given index | ||||
| func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*TrackedTime, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -106,6 +112,9 @@ func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*T | ||||
|  | ||||
| // ListIssueTrackedTimes list tracked times of a single issue for a given repository | ||||
| func (c *Client) ListIssueTrackedTimes(owner, repo string, index int64, opt ListTrackedTimesOptions) ([]*TrackedTime, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index)) | ||||
| 	opt.setDefaults() | ||||
| 	link.RawQuery = opt.QueryEncode() | ||||
| @@ -116,12 +125,18 @@ func (c *Client) ListIssueTrackedTimes(owner, repo string, index int64, opt List | ||||
|  | ||||
| // ResetIssueTime reset tracked time of a single issue for a given repository | ||||
| func (c *Client) ResetIssueTime(owner, repo string, index int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), jsonHeader, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // DeleteTime delete a specific tracked time by id of a single issue for a given repository | ||||
| func (c *Client) DeleteTime(owner, repo string, index, timeID int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times/%d", owner, repo, index, timeID), jsonHeader, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										9
									
								
								vendor/code.gitea.io/sdk/gitea/list_options.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								vendor/code.gitea.io/sdk/gitea/list_options.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -26,8 +26,13 @@ func (o ListOptions) getURLQuery() url.Values { | ||||
| 	return query | ||||
| } | ||||
|  | ||||
| func (o ListOptions) setDefaults() { | ||||
| 	if o.Page < 1 { | ||||
| // setDefaults set default pagination options if none or wrong are set | ||||
| // if you set -1 as page it will set all to 0 | ||||
| func (o *ListOptions) setDefaults() { | ||||
| 	if o.Page < 0 { | ||||
| 		o.Page, o.PageSize = 0, 0 | ||||
| 		return | ||||
| 	} else if o.Page == 0 { | ||||
| 		o.Page = 1 | ||||
| 	} | ||||
|  | ||||
|   | ||||
							
								
								
									
										60
									
								
								vendor/code.gitea.io/sdk/gitea/notifications.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										60
									
								
								vendor/code.gitea.io/sdk/gitea/notifications.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,11 +29,11 @@ type NotificationThread struct { | ||||
|  | ||||
| // NotificationSubject contains the notification subject (Issue/Pull/Commit) | ||||
| type NotificationSubject struct { | ||||
| 	Title            string    `json:"title"` | ||||
| 	URL              string    `json:"url"` | ||||
| 	LatestCommentURL string    `json:"latest_comment_url"` | ||||
| 	Type             string    `json:"type"` | ||||
| 	State            StateType `json:"state"` | ||||
| 	Title            string             `json:"title"` | ||||
| 	URL              string             `json:"url"` | ||||
| 	LatestCommentURL string             `json:"latest_comment_url"` | ||||
| 	Type             NotifySubjectType  `json:"type"` | ||||
| 	State            NotifySubjectState `json:"state"` | ||||
| } | ||||
|  | ||||
| // NotifyStatus notification status type | ||||
| @@ -48,12 +48,39 @@ const ( | ||||
| 	NotifyStatusPinned NotifyStatus = "pinned" | ||||
| ) | ||||
|  | ||||
| // NotifySubjectType represent type of notification subject | ||||
| type NotifySubjectType string | ||||
|  | ||||
| const ( | ||||
| 	// NotifySubjectIssue an issue is subject of an notification | ||||
| 	NotifySubjectIssue NotifySubjectType = "Issue" | ||||
| 	// NotifySubjectPull an pull is subject of an notification | ||||
| 	NotifySubjectPull NotifySubjectType = "Pull" | ||||
| 	// NotifySubjectCommit an commit is subject of an notification | ||||
| 	NotifySubjectCommit NotifySubjectType = "Commit" | ||||
| 	// NotifySubjectRepository an repository is subject of an notification | ||||
| 	NotifySubjectRepository NotifySubjectType = "Repository" | ||||
| ) | ||||
|  | ||||
| // NotifySubjectState reflect state of notification subject | ||||
| type NotifySubjectState string | ||||
|  | ||||
| const ( | ||||
| 	// NotifySubjectOpen if subject is a pull/issue and is open at the moment | ||||
| 	NotifySubjectOpen NotifySubjectState = "open" | ||||
| 	// NotifySubjectClosed if subject is a pull/issue and is closed at the moment | ||||
| 	NotifySubjectClosed NotifySubjectState = "closed" | ||||
| 	// NotifySubjectMerged if subject is a pull and got merged | ||||
| 	NotifySubjectMerged NotifySubjectState = "merged" | ||||
| ) | ||||
|  | ||||
| // ListNotificationOptions represents the filter options | ||||
| type ListNotificationOptions struct { | ||||
| 	ListOptions | ||||
| 	Since  time.Time | ||||
| 	Before time.Time | ||||
| 	Status []NotifyStatus | ||||
| 	Since        time.Time | ||||
| 	Before       time.Time | ||||
| 	Status       []NotifyStatus | ||||
| 	SubjectTypes []NotifySubjectType | ||||
| } | ||||
|  | ||||
| // MarkNotificationOptions represents the filter & modify options | ||||
| @@ -75,6 +102,9 @@ func (opt *ListNotificationOptions) QueryEncode() string { | ||||
| 	for _, s := range opt.Status { | ||||
| 		query.Add("status-types", string(s)) | ||||
| 	} | ||||
| 	for _, s := range opt.SubjectTypes { | ||||
| 		query.Add("subject-type", string(s)) | ||||
| 	} | ||||
| 	return query.Encode() | ||||
| } | ||||
|  | ||||
| @@ -176,14 +206,17 @@ func (c *Client) ReadNotifications(opt MarkNotificationOptions) (*Response, erro | ||||
| } | ||||
|  | ||||
| // ListRepoNotifications list users's notification threads on a specific repo | ||||
| func (c *Client) ListRepoNotifications(owner, reponame string, opt ListNotificationOptions) ([]*NotificationThread, *Response, error) { | ||||
| func (c *Client) ListRepoNotifications(owner, repo string, opt ListNotificationOptions) ([]*NotificationThread, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(c); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/notifications", owner, reponame)) | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/notifications", owner, repo)) | ||||
| 	link.RawQuery = opt.QueryEncode() | ||||
| 	threads := make([]*NotificationThread, 0, 10) | ||||
| 	resp, err := c.getParsedResponse("GET", link.String(), nil, nil, &threads) | ||||
| @@ -191,14 +224,17 @@ func (c *Client) ListRepoNotifications(owner, reponame string, opt ListNotificat | ||||
| } | ||||
|  | ||||
| // ReadRepoNotifications mark notification threads as read on a specific repo | ||||
| func (c *Client) ReadRepoNotifications(owner, reponame string, opt MarkNotificationOptions) (*Response, error) { | ||||
| func (c *Client) ReadRepoNotifications(owner, repo string, opt MarkNotificationOptions) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(c); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/notifications", owner, reponame)) | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/notifications", owner, repo)) | ||||
| 	link.RawQuery = opt.QueryEncode() | ||||
| 	_, resp, err := c.getResponse("PUT", link.String(), nil, nil) | ||||
| 	return resp, err | ||||
|   | ||||
							
								
								
									
										25
									
								
								vendor/code.gitea.io/sdk/gitea/org.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								vendor/code.gitea.io/sdk/gitea/org.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -52,6 +52,9 @@ func (c *Client) ListMyOrgs(opt ListOrgsOptions) ([]*Organization, *Response, er | ||||
|  | ||||
| // ListUserOrgs list all of some user's organizations | ||||
| func (c *Client) ListUserOrgs(user string, opt ListOrgsOptions) ([]*Organization, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	orgs := make([]*Organization, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/orgs?%s", user, opt.getURLQuery().Encode()), nil, nil, &orgs) | ||||
| @@ -60,6 +63,9 @@ func (c *Client) ListUserOrgs(user string, opt ListOrgsOptions) ([]*Organization | ||||
|  | ||||
| // GetOrg get one organization by name | ||||
| func (c *Client) GetOrg(orgname string) (*Organization, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&orgname); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	org := new(Organization) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org) | ||||
| 	return org, resp, err | ||||
| @@ -67,12 +73,13 @@ func (c *Client) GetOrg(orgname string) (*Organization, *Response, error) { | ||||
|  | ||||
| // CreateOrgOption options for creating an organization | ||||
| type CreateOrgOption struct { | ||||
| 	Name        string      `json:"username"` | ||||
| 	FullName    string      `json:"full_name"` | ||||
| 	Description string      `json:"description"` | ||||
| 	Website     string      `json:"website"` | ||||
| 	Location    string      `json:"location"` | ||||
| 	Visibility  VisibleType `json:"visibility"` | ||||
| 	Name                      string      `json:"username"` | ||||
| 	FullName                  string      `json:"full_name"` | ||||
| 	Description               string      `json:"description"` | ||||
| 	Website                   string      `json:"website"` | ||||
| 	Location                  string      `json:"location"` | ||||
| 	Visibility                VisibleType `json:"visibility"` | ||||
| 	RepoAdminChangeTeamAccess bool        `json:"repo_admin_change_team_access"` | ||||
| } | ||||
|  | ||||
| // checkVisibilityOpt check if mode exist | ||||
| @@ -124,6 +131,9 @@ func (opt EditOrgOption) Validate() error { | ||||
|  | ||||
| // EditOrg modify one organization via options | ||||
| func (c *Client) EditOrg(orgname string, opt EditOrgOption) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&orgname); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -137,6 +147,9 @@ func (c *Client) EditOrg(orgname string, opt EditOrgOption) (*Response, error) { | ||||
|  | ||||
| // DeleteOrg deletes an organization | ||||
| func (c *Client) DeleteOrg(orgname string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&orgname); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/orgs/%s", orgname), jsonHeader, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										32
									
								
								vendor/code.gitea.io/sdk/gitea/org_member.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								vendor/code.gitea.io/sdk/gitea/org_member.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -12,7 +12,10 @@ import ( | ||||
|  | ||||
| // DeleteOrgMembership remove a member from an organization | ||||
| func (c *Client) DeleteOrgMembership(org, user string) (*Response, error) { | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/orgs/%s/members/%s", url.PathEscape(org), url.PathEscape(user)), nil, nil) | ||||
| 	if err := escapeValidatePathSegments(&org, &user); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/orgs/%s/members/%s", org, user), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| @@ -23,10 +26,13 @@ type ListOrgMembershipOption struct { | ||||
|  | ||||
| // ListOrgMembership list an organization's members | ||||
| func (c *Client) ListOrgMembership(org string, opt ListOrgMembershipOption) ([]*User, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	users := make([]*User, 0, opt.PageSize) | ||||
|  | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/orgs/%s/members", url.PathEscape(org))) | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/orgs/%s/members", org)) | ||||
| 	link.RawQuery = opt.getURLQuery().Encode() | ||||
| 	resp, err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &users) | ||||
| 	return users, resp, err | ||||
| @@ -34,10 +40,13 @@ func (c *Client) ListOrgMembership(org string, opt ListOrgMembershipOption) ([]* | ||||
|  | ||||
| // ListPublicOrgMembership list an organization's members | ||||
| func (c *Client) ListPublicOrgMembership(org string, opt ListOrgMembershipOption) ([]*User, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	users := make([]*User, 0, opt.PageSize) | ||||
|  | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/orgs/%s/public_members", url.PathEscape(org))) | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/orgs/%s/public_members", org)) | ||||
| 	link.RawQuery = opt.getURLQuery().Encode() | ||||
| 	resp, err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &users) | ||||
| 	return users, resp, err | ||||
| @@ -45,7 +54,10 @@ func (c *Client) ListPublicOrgMembership(org string, opt ListOrgMembershipOption | ||||
|  | ||||
| // CheckOrgMembership Check if a user is a member of an organization | ||||
| func (c *Client) CheckOrgMembership(org, user string) (bool, *Response, error) { | ||||
| 	status, resp, err := c.getStatusCode("GET", fmt.Sprintf("/orgs/%s/members/%s", url.PathEscape(org), url.PathEscape(user)), nil, nil) | ||||
| 	if err := escapeValidatePathSegments(&org, &user); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| 	status, resp, err := c.getStatusCode("GET", fmt.Sprintf("/orgs/%s/members/%s", org, user), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return false, resp, err | ||||
| 	} | ||||
| @@ -61,7 +73,10 @@ func (c *Client) CheckOrgMembership(org, user string) (bool, *Response, error) { | ||||
|  | ||||
| // CheckPublicOrgMembership Check if a user is a member of an organization | ||||
| func (c *Client) CheckPublicOrgMembership(org, user string) (bool, *Response, error) { | ||||
| 	status, resp, err := c.getStatusCode("GET", fmt.Sprintf("/orgs/%s/public_members/%s", url.PathEscape(org), url.PathEscape(user)), nil, nil) | ||||
| 	if err := escapeValidatePathSegments(&org, &user); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| 	status, resp, err := c.getStatusCode("GET", fmt.Sprintf("/orgs/%s/public_members/%s", org, user), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return false, resp, err | ||||
| 	} | ||||
| @@ -77,15 +92,18 @@ func (c *Client) CheckPublicOrgMembership(org, user string) (bool, *Response, er | ||||
|  | ||||
| // SetPublicOrgMembership publicize/conceal a user's membership | ||||
| func (c *Client) SetPublicOrgMembership(org, user string, visible bool) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org, &user); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	var ( | ||||
| 		status int | ||||
| 		err    error | ||||
| 		resp   *Response | ||||
| 	) | ||||
| 	if visible { | ||||
| 		status, resp, err = c.getStatusCode("PUT", fmt.Sprintf("/orgs/%s/public_members/%s", url.PathEscape(org), url.PathEscape(user)), nil, nil) | ||||
| 		status, resp, err = c.getStatusCode("PUT", fmt.Sprintf("/orgs/%s/public_members/%s", org, user), nil, nil) | ||||
| 	} else { | ||||
| 		status, resp, err = c.getStatusCode("DELETE", fmt.Sprintf("/orgs/%s/public_members/%s", url.PathEscape(org), url.PathEscape(user)), nil, nil) | ||||
| 		status, resp, err = c.getStatusCode("DELETE", fmt.Sprintf("/orgs/%s/public_members/%s", org, user), nil, nil) | ||||
| 	} | ||||
| 	if err != nil { | ||||
| 		return resp, err | ||||
|   | ||||
							
								
								
									
										86
									
								
								vendor/code.gitea.io/sdk/gitea/org_team.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										86
									
								
								vendor/code.gitea.io/sdk/gitea/org_team.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -12,17 +12,38 @@ import ( | ||||
|  | ||||
| // Team represents a team in an organization | ||||
| type Team struct { | ||||
| 	ID                      int64         `json:"id"` | ||||
| 	Name                    string        `json:"name"` | ||||
| 	Description             string        `json:"description"` | ||||
| 	Organization            *Organization `json:"organization"` | ||||
| 	Permission              AccessMode    `json:"permission"` | ||||
| 	CanCreateOrgRepo        bool          `json:"can_create_org_repo"` | ||||
| 	IncludesAllRepositories bool          `json:"includes_all_repositories"` | ||||
| 	// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] | ||||
| 	Units []string `json:"units"` | ||||
| 	ID                      int64          `json:"id"` | ||||
| 	Name                    string         `json:"name"` | ||||
| 	Description             string         `json:"description"` | ||||
| 	Organization            *Organization  `json:"organization"` | ||||
| 	Permission              AccessMode     `json:"permission"` | ||||
| 	CanCreateOrgRepo        bool           `json:"can_create_org_repo"` | ||||
| 	IncludesAllRepositories bool           `json:"includes_all_repositories"` | ||||
| 	Units                   []RepoUnitType `json:"units"` | ||||
| } | ||||
|  | ||||
| // RepoUnitType represent all unit types of a repo gitea currently offer | ||||
| type RepoUnitType string | ||||
|  | ||||
| const ( | ||||
| 	// RepoUnitCode represent file view of a repository | ||||
| 	RepoUnitCode RepoUnitType = "repo.code" | ||||
| 	// RepoUnitIssues represent issues of a repository | ||||
| 	RepoUnitIssues RepoUnitType = "repo.issues" | ||||
| 	// RepoUnitPulls represent pulls of a repository | ||||
| 	RepoUnitPulls RepoUnitType = "repo.pulls" | ||||
| 	// RepoUnitExtIssues represent external issues of a repository | ||||
| 	RepoUnitExtIssues RepoUnitType = "repo.ext_issues" | ||||
| 	// RepoUnitWiki represent wiki of a repository | ||||
| 	RepoUnitWiki RepoUnitType = "repo.wiki" | ||||
| 	// RepoUnitExtWiki represent external wiki of a repository | ||||
| 	RepoUnitExtWiki RepoUnitType = "repo.ext_wiki" | ||||
| 	// RepoUnitReleases represent releases of a repository | ||||
| 	RepoUnitReleases RepoUnitType = "repo.releases" | ||||
| 	// RepoUnitProjects represent projects of a repository | ||||
| 	RepoUnitProjects RepoUnitType = "repo.projects" | ||||
| ) | ||||
|  | ||||
| // ListTeamsOptions options for listing teams | ||||
| type ListTeamsOptions struct { | ||||
| 	ListOptions | ||||
| @@ -30,6 +51,9 @@ type ListTeamsOptions struct { | ||||
|  | ||||
| // ListOrgTeams lists all teams of an organization | ||||
| func (c *Client) ListOrgTeams(org string, opt ListTeamsOptions) ([]*Team, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	teams := make([]*Team, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/teams?%s", org, opt.getURLQuery().Encode()), nil, nil, &teams) | ||||
| @@ -53,13 +77,12 @@ func (c *Client) GetTeam(id int64) (*Team, *Response, error) { | ||||
|  | ||||
| // CreateTeamOption options for creating a team | ||||
| type CreateTeamOption struct { | ||||
| 	Name                    string     `json:"name"` | ||||
| 	Description             string     `json:"description"` | ||||
| 	Permission              AccessMode `json:"permission"` | ||||
| 	CanCreateOrgRepo        bool       `json:"can_create_org_repo"` | ||||
| 	IncludesAllRepositories bool       `json:"includes_all_repositories"` | ||||
| 	// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] | ||||
| 	Units []string `json:"units"` | ||||
| 	Name                    string         `json:"name"` | ||||
| 	Description             string         `json:"description"` | ||||
| 	Permission              AccessMode     `json:"permission"` | ||||
| 	CanCreateOrgRepo        bool           `json:"can_create_org_repo"` | ||||
| 	IncludesAllRepositories bool           `json:"includes_all_repositories"` | ||||
| 	Units                   []RepoUnitType `json:"units"` | ||||
| } | ||||
|  | ||||
| // Validate the CreateTeamOption struct | ||||
| @@ -83,6 +106,9 @@ func (opt CreateTeamOption) Validate() error { | ||||
|  | ||||
| // CreateTeam creates a team for an organization | ||||
| func (c *Client) CreateTeam(org string, opt CreateTeamOption) (*Team, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -97,13 +123,12 @@ func (c *Client) CreateTeam(org string, opt CreateTeamOption) (*Team, *Response, | ||||
|  | ||||
| // EditTeamOption options for editing a team | ||||
| type EditTeamOption struct { | ||||
| 	Name                    string     `json:"name"` | ||||
| 	Description             *string    `json:"description"` | ||||
| 	Permission              AccessMode `json:"permission"` | ||||
| 	CanCreateOrgRepo        *bool      `json:"can_create_org_repo"` | ||||
| 	IncludesAllRepositories *bool      `json:"includes_all_repositories"` | ||||
| 	// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] | ||||
| 	Units []string `json:"units"` | ||||
| 	Name                    string         `json:"name"` | ||||
| 	Description             *string        `json:"description"` | ||||
| 	Permission              AccessMode     `json:"permission"` | ||||
| 	CanCreateOrgRepo        *bool          `json:"can_create_org_repo"` | ||||
| 	IncludesAllRepositories *bool          `json:"includes_all_repositories"` | ||||
| 	Units                   []RepoUnitType `json:"units"` | ||||
| } | ||||
|  | ||||
| // Validate the EditTeamOption struct | ||||
| @@ -159,6 +184,9 @@ func (c *Client) ListTeamMembers(id int64, opt ListTeamMembersOptions) ([]*User, | ||||
|  | ||||
| // GetTeamMember gets a member of a team | ||||
| func (c *Client) GetTeamMember(id int64, user string) (*User, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	m := new(User) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/teams/%d/members/%s", id, user), nil, nil, m) | ||||
| 	return m, resp, err | ||||
| @@ -166,12 +194,18 @@ func (c *Client) GetTeamMember(id int64, user string) (*User, *Response, error) | ||||
|  | ||||
| // AddTeamMember adds a member to a team | ||||
| func (c *Client) AddTeamMember(id int64, user string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("PUT", fmt.Sprintf("/teams/%d/members/%s", id, user), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // RemoveTeamMember removes a member from a team | ||||
| func (c *Client) RemoveTeamMember(id int64, user string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/teams/%d/members/%s", id, user), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
| @@ -191,12 +225,18 @@ func (c *Client) ListTeamRepositories(id int64, opt ListTeamRepositoriesOptions) | ||||
|  | ||||
| // AddTeamRepository adds a repository to a team | ||||
| func (c *Client) AddTeamRepository(id int64, org, repo string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("PUT", fmt.Sprintf("/teams/%d/repos/%s/%s", id, org, repo), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // RemoveTeamRepository removes a repository from a team | ||||
| func (c *Client) RemoveTeamRepository(id int64, org, repo string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/teams/%d/repos/%s/%s", id, org, repo), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										71
									
								
								vendor/code.gitea.io/sdk/gitea/pull.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										71
									
								
								vendor/code.gitea.io/sdk/gitea/pull.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -99,19 +99,37 @@ func (opt *ListPullRequestsOptions) QueryEncode() string { | ||||
|  | ||||
| // ListRepoPullRequests list PRs of one repository | ||||
| func (c *Client) ListRepoPullRequests(owner, repo string, opt ListPullRequestsOptions) ([]*PullRequest, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	prs := make([]*PullRequest, 0, opt.PageSize) | ||||
|  | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/pulls", owner, repo)) | ||||
| 	link.RawQuery = opt.QueryEncode() | ||||
| 	resp, err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &prs) | ||||
| 	if c.checkServerVersionGreaterThanOrEqual(version1_14_0) != nil { | ||||
| 		for i := range prs { | ||||
| 			if err := fixPullHeadSha(c, prs[i]); err != nil { | ||||
| 				return prs, resp, err | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return prs, resp, err | ||||
| } | ||||
|  | ||||
| // GetPullRequest get information of one PR | ||||
| func (c *Client) GetPullRequest(owner, repo string, index int64) (*PullRequest, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	pr := new(PullRequest) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d", owner, repo, index), nil, nil, pr) | ||||
| 	if c.checkServerVersionGreaterThanOrEqual(version1_14_0) != nil { | ||||
| 		if err := fixPullHeadSha(c, pr); err != nil { | ||||
| 			return pr, resp, err | ||||
| 		} | ||||
| 	} | ||||
| 	return pr, resp, err | ||||
| } | ||||
|  | ||||
| @@ -130,6 +148,9 @@ type CreatePullRequestOption struct { | ||||
|  | ||||
| // CreatePullRequest create pull request with options | ||||
| func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOption) (*PullRequest, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| @@ -169,6 +190,9 @@ func (opt EditPullRequestOption) Validate(c *Client) error { | ||||
|  | ||||
| // EditPullRequest modify pull request with PR id and options | ||||
| func (c *Client) EditPullRequest(owner, repo string, index int64, opt EditPullRequestOption) (*PullRequest, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(c); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -202,6 +226,9 @@ func (opt MergePullRequestOption) Validate(c *Client) error { | ||||
|  | ||||
| // MergePullRequest merge a PR to repository by PR id | ||||
| func (c *Client) MergePullRequest(owner, repo string, index int64, opt MergePullRequestOption) (bool, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(c); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| @@ -218,6 +245,9 @@ func (c *Client) MergePullRequest(owner, repo string, index int64, opt MergePull | ||||
|  | ||||
| // IsPullRequestMerged test if one PR is merged to one repository | ||||
| func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| 	status, resp, err := c.getStatusCode("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), nil, nil) | ||||
|  | ||||
| 	if err != nil { | ||||
| @@ -229,6 +259,9 @@ func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, *Re | ||||
|  | ||||
| // getPullRequestDiffOrPatch gets the patch or diff file as bytes for a PR | ||||
| func (c *Client) getPullRequestDiffOrPatch(owner, repo, kind string, index int64) ([]byte, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &kind); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { | ||||
| 		r, _, err2 := c.GetRepo(owner, repo) | ||||
| 		if err2 != nil { | ||||
| @@ -251,3 +284,41 @@ func (c *Client) GetPullRequestPatch(owner, repo string, index int64) ([]byte, * | ||||
| func (c *Client) GetPullRequestDiff(owner, repo string, index int64) ([]byte, *Response, error) { | ||||
| 	return c.getPullRequestDiffOrPatch(owner, repo, "diff", index) | ||||
| } | ||||
|  | ||||
| // ListPullRequestCommitsOptions options for listing pull requests | ||||
| type ListPullRequestCommitsOptions struct { | ||||
| 	ListOptions | ||||
| } | ||||
|  | ||||
| // ListPullRequestCommits list commits for a pull request | ||||
| func (c *Client) ListPullRequestCommits(owner, repo string, index int64, opt ListPullRequestCommitsOptions) ([]*Commit, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/pulls/%d/commits", owner, repo, index)) | ||||
| 	opt.setDefaults() | ||||
| 	commits := make([]*Commit, 0, opt.PageSize) | ||||
| 	link.RawQuery = opt.getURLQuery().Encode() | ||||
| 	resp, err := c.getParsedResponse("GET", link.String(), nil, nil, &commits) | ||||
| 	return commits, resp, err | ||||
| } | ||||
|  | ||||
| // fixPullHeadSha is a workaround for https://github.com/go-gitea/gitea/issues/12675 | ||||
| // When no head sha is available, this is because the branch got deleted in the base repo. | ||||
| // pr.Head.Ref points in this case not to the head repo branch name, but the base repo ref, | ||||
| // which stays available to resolve the commit sha. This is fixed for gitea >= 1.14.0 | ||||
| func fixPullHeadSha(client *Client, pr *PullRequest) error { | ||||
| 	if pr.Base != nil && pr.Base.Repository != nil && pr.Base.Repository.Owner != nil && | ||||
| 		pr.Head != nil && pr.Head.Ref != "" && pr.Head.Sha == "" { | ||||
| 		owner := pr.Base.Repository.Owner.UserName | ||||
| 		repo := pr.Base.Repository.Name | ||||
| 		refs, _, err := client.GetRepoRefs(owner, repo, pr.Head.Ref) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} else if len(refs) == 0 { | ||||
| 			return fmt.Errorf("unable to resolve PR ref '%s'", pr.Head.Ref) | ||||
| 		} | ||||
| 		pr.Head.Sha = refs[0].Object.SHA | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										31
									
								
								vendor/code.gitea.io/sdk/gitea/pull_review.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										31
									
								
								vendor/code.gitea.io/sdk/gitea/pull_review.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -57,6 +57,7 @@ type PullReviewComment struct { | ||||
| 	Body     string `json:"body"` | ||||
| 	Reviewer *User  `json:"user"` | ||||
| 	ReviewID int64  `json:"pull_request_review_id"` | ||||
| 	Resolver *User  `json:"resolver"` | ||||
|  | ||||
| 	Created time.Time `json:"created_at"` | ||||
| 	Updated time.Time `json:"updated_at"` | ||||
| @@ -147,6 +148,9 @@ func (opt CreatePullReviewComment) Validate() error { | ||||
|  | ||||
| // ListPullReviews lists all reviews of a pull request | ||||
| func (c *Client) ListPullReviews(owner, repo string, index int64, opt ListPullReviewsOptions) ([]*PullReview, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -162,6 +166,9 @@ func (c *Client) ListPullReviews(owner, repo string, index int64, opt ListPullRe | ||||
|  | ||||
| // GetPullReview gets a specific review of a pull request | ||||
| func (c *Client) GetPullReview(owner, repo string, index, id int64) (*PullReview, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -173,6 +180,9 @@ func (c *Client) GetPullReview(owner, repo string, index, id int64) (*PullReview | ||||
|  | ||||
| // ListPullReviewComments lists all comments of a pull request review | ||||
| func (c *Client) ListPullReviewComments(owner, repo string, index, id int64) ([]*PullReviewComment, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -185,6 +195,9 @@ func (c *Client) ListPullReviewComments(owner, repo string, index, id int64) ([] | ||||
|  | ||||
| // DeletePullReview delete a specific review from a pull request | ||||
| func (c *Client) DeletePullReview(owner, repo string, index, id int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -195,6 +208,9 @@ func (c *Client) DeletePullReview(owner, repo string, index, id int64) (*Respons | ||||
|  | ||||
| // CreatePullReview create a review to an pull request | ||||
| func (c *Client) CreatePullReview(owner, repo string, index int64, opt CreatePullReviewOptions) (*PullReview, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -215,6 +231,9 @@ func (c *Client) CreatePullReview(owner, repo string, index int64, opt CreatePul | ||||
|  | ||||
| // SubmitPullReview submit a pending review to an pull request | ||||
| func (c *Client) SubmitPullReview(owner, repo string, index, id int64, opt SubmitPullReviewOptions) (*PullReview, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -235,6 +254,9 @@ func (c *Client) SubmitPullReview(owner, repo string, index, id int64, opt Submi | ||||
|  | ||||
| // CreateReviewRequests create review requests to an pull request | ||||
| func (c *Client) CreateReviewRequests(owner, repo string, index int64, opt PullReviewRequestOptions) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_14_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -251,6 +273,9 @@ func (c *Client) CreateReviewRequests(owner, repo string, index int64, opt PullR | ||||
|  | ||||
| // DeleteReviewRequests delete review requests to an pull request | ||||
| func (c *Client) DeleteReviewRequests(owner, repo string, index int64, opt PullReviewRequestOptions) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_14_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -267,6 +292,9 @@ func (c *Client) DeleteReviewRequests(owner, repo string, index int64, opt PullR | ||||
|  | ||||
| // DismissPullReview dismiss a review for a pull request | ||||
| func (c *Client) DismissPullReview(owner, repo string, index, id int64, opt DismissPullReviewOptions) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_14_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -283,6 +311,9 @@ func (c *Client) DismissPullReview(owner, repo string, index, id int64, opt Dism | ||||
|  | ||||
| // UnDismissPullReview cancel to dismiss a review for a pull request | ||||
| func (c *Client) UnDismissPullReview(owner, repo string, index, id int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_14_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										63
									
								
								vendor/code.gitea.io/sdk/gitea/release.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										63
									
								
								vendor/code.gitea.io/sdk/gitea/release.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -35,35 +35,60 @@ type Release struct { | ||||
| // ListReleasesOptions options for listing repository's releases | ||||
| type ListReleasesOptions struct { | ||||
| 	ListOptions | ||||
| 	IsDraft      *bool | ||||
| 	IsPreRelease *bool | ||||
| } | ||||
|  | ||||
| // QueryEncode turns options into querystring argument | ||||
| func (opt *ListReleasesOptions) QueryEncode() string { | ||||
| 	query := opt.getURLQuery() | ||||
|  | ||||
| 	if opt.IsDraft != nil { | ||||
| 		query.Add("draft", fmt.Sprintf("%t", *opt.IsDraft)) | ||||
| 	} | ||||
| 	if opt.IsPreRelease != nil { | ||||
| 		query.Add("draft", fmt.Sprintf("%t", *opt.IsPreRelease)) | ||||
| 	} | ||||
|  | ||||
| 	return query.Encode() | ||||
| } | ||||
|  | ||||
| // ListReleases list releases of a repository | ||||
| func (c *Client) ListReleases(user, repo string, opt ListReleasesOptions) ([]*Release, *Response, error) { | ||||
| func (c *Client) ListReleases(owner, repo string, opt ListReleasesOptions) ([]*Release, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	releases := make([]*Release, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases?%s", user, repo, opt.getURLQuery().Encode()), | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases?%s", owner, repo, opt.QueryEncode()), | ||||
| 		nil, nil, &releases) | ||||
| 	return releases, resp, err | ||||
| } | ||||
|  | ||||
| // GetRelease get a release of a repository by id | ||||
| func (c *Client) GetRelease(user, repo string, id int64) (*Release, *Response, error) { | ||||
| func (c *Client) GetRelease(owner, repo string, id int64) (*Release, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	r := new(Release) | ||||
| 	resp, err := c.getParsedResponse("GET", | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id), | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases/%d", owner, repo, id), | ||||
| 		jsonHeader, nil, &r) | ||||
| 	return r, resp, err | ||||
| } | ||||
|  | ||||
| // GetReleaseByTag get a release of a repository by tag | ||||
| func (c *Client) GetReleaseByTag(user, repo string, tag string) (*Release, *Response, error) { | ||||
| func (c *Client) GetReleaseByTag(owner, repo string, tag string) (*Release, *Response, error) { | ||||
| 	if c.checkServerVersionGreaterThanOrEqual(version1_13_0) != nil { | ||||
| 		return c.fallbackGetReleaseByTag(user, repo, tag) | ||||
| 		return c.fallbackGetReleaseByTag(owner, repo, tag) | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &tag); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	r := new(Release) | ||||
| 	resp, err := c.getParsedResponse("GET", | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases/tags/%s", user, repo, tag), | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases/tags/%s", owner, repo, tag), | ||||
| 		nil, nil, &r) | ||||
| 	return r, resp, err | ||||
| } | ||||
| @@ -87,7 +112,10 @@ func (opt CreateReleaseOption) Validate() error { | ||||
| } | ||||
|  | ||||
| // CreateRelease create a release | ||||
| func (c *Client) CreateRelease(user, repo string, opt CreateReleaseOption) (*Release, *Response, error) { | ||||
| func (c *Client) CreateRelease(owner, repo string, opt CreateReleaseOption) (*Release, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -97,7 +125,7 @@ func (c *Client) CreateRelease(user, repo string, opt CreateReleaseOption) (*Rel | ||||
| 	} | ||||
| 	r := new(Release) | ||||
| 	resp, err := c.getParsedResponse("POST", | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases", user, repo), | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases", owner, repo), | ||||
| 		jsonHeader, bytes.NewReader(body), r) | ||||
| 	return r, resp, err | ||||
| } | ||||
| @@ -113,20 +141,26 @@ type EditReleaseOption struct { | ||||
| } | ||||
|  | ||||
| // EditRelease edit a release | ||||
| func (c *Client) EditRelease(user, repo string, id int64, form EditReleaseOption) (*Release, *Response, error) { | ||||
| func (c *Client) EditRelease(owner, repo string, id int64, form EditReleaseOption) (*Release, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(form) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	r := new(Release) | ||||
| 	resp, err := c.getParsedResponse("PATCH", | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id), | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases/%d", owner, repo, id), | ||||
| 		jsonHeader, bytes.NewReader(body), r) | ||||
| 	return r, resp, err | ||||
| } | ||||
|  | ||||
| // DeleteRelease delete a release from a repository, keeping its tag | ||||
| func (c *Client) DeleteRelease(user, repo string, id int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", | ||||
| 		fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id), | ||||
| 		nil, nil) | ||||
| @@ -135,6 +169,9 @@ func (c *Client) DeleteRelease(user, repo string, id int64) (*Response, error) { | ||||
|  | ||||
| // DeleteReleaseByTag deletes a release frm a repository by tag | ||||
| func (c *Client) DeleteReleaseByTag(user, repo string, tag string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &tag); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_14_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -145,9 +182,9 @@ func (c *Client) DeleteReleaseByTag(user, repo string, tag string) (*Response, e | ||||
| } | ||||
|  | ||||
| // fallbackGetReleaseByTag is fallback for old gitea installations ( < 1.13.0 ) | ||||
| func (c *Client) fallbackGetReleaseByTag(user, repo string, tag string) (*Release, *Response, error) { | ||||
| func (c *Client) fallbackGetReleaseByTag(owner, repo string, tag string) (*Release, *Response, error) { | ||||
| 	for i := 1; ; i++ { | ||||
| 		rl, resp, err := c.ListReleases(user, repo, ListReleasesOptions{ListOptions{Page: i}}) | ||||
| 		rl, resp, err := c.ListReleases(owner, repo, ListReleasesOptions{ListOptions: ListOptions{Page: i}}) | ||||
| 		if err != nil { | ||||
| 			return nil, resp, err | ||||
| 		} | ||||
|   | ||||
							
								
								
									
										51
									
								
								vendor/code.gitea.io/sdk/gitea/repo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								vendor/code.gitea.io/sdk/gitea/repo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -93,6 +93,7 @@ type Repository struct { | ||||
| 	AvatarURL                 string           `json:"avatar_url"` | ||||
| 	Internal                  bool             `json:"internal"` | ||||
| 	MirrorInterval            string           `json:"mirror_interval"` | ||||
| 	DefaultMergeStyle         MergeStyle       `json:"default_merge_style"` | ||||
| } | ||||
|  | ||||
| // RepoType represent repo type | ||||
| @@ -138,6 +139,9 @@ func (c *Client) ListMyRepos(opt ListReposOptions) ([]*Repository, *Response, er | ||||
|  | ||||
| // ListUserRepos list all repositories of one user by user's name | ||||
| func (c *Client) ListUserRepos(user string, opt ListReposOptions) ([]*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	repos := make([]*Repository, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/repos?%s", user, opt.getURLQuery().Encode()), nil, nil, &repos) | ||||
| @@ -151,6 +155,9 @@ type ListOrgReposOptions struct { | ||||
|  | ||||
| // ListOrgRepos list all repositories of one organization by organization's name | ||||
| func (c *Client) ListOrgRepos(org string, opt ListOrgReposOptions) ([]*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	repos := make([]*Repository, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/repos?%s", org, opt.getURLQuery().Encode()), nil, nil, &repos) | ||||
| @@ -351,6 +358,9 @@ func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, *Response, error | ||||
|  | ||||
| // CreateOrgRepo creates an organization repository for authenticated user. | ||||
| func (c *Client) CreateOrgRepo(org string, opt CreateRepoOption) (*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&org); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(c); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -365,11 +375,21 @@ func (c *Client) CreateOrgRepo(org string, opt CreateRepoOption) (*Repository, * | ||||
|  | ||||
| // GetRepo returns information of a repository of given owner. | ||||
| func (c *Client) GetRepo(owner, reponame string) (*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &reponame); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	repo := new(Repository) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s", owner, reponame), nil, nil, repo) | ||||
| 	return repo, resp, err | ||||
| } | ||||
|  | ||||
| // GetRepoByID returns information of a repository by a giver repository ID. | ||||
| func (c *Client) GetRepoByID(id int64) (*Repository, *Response, error) { | ||||
| 	repo := new(Repository) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repositories/%d", id), nil, nil, repo) | ||||
| 	return repo, resp, err | ||||
| } | ||||
|  | ||||
| // EditRepoOption options when editing a repository's properties | ||||
| type EditRepoOption struct { | ||||
| 	// name of the repository | ||||
| @@ -414,10 +434,20 @@ type EditRepoOption struct { | ||||
| 	Archived *bool `json:"archived,omitempty"` | ||||
| 	// set to a string like `8h30m0s` to set the mirror interval time | ||||
| 	MirrorInterval *string `json:"mirror_interval,omitempty"` | ||||
| 	// either `true` to allow mark pr as merged manually, or `false` to prevent it. `has_pull_requests` must be `true`. | ||||
| 	AllowManualMerge *bool `json:"allow_manual_merge,omitempty"` | ||||
| 	// either `true` to enable AutodetectManualMerge, or `false` to prevent it. `has_pull_requests` must be `true`, Note: In some special cases, misjudgments can occur. | ||||
| 	AutodetectManualMerge *bool `json:"autodetect_manual_merge,omitempty"` | ||||
| 	// set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", or "squash". `has_pull_requests` must be `true`. | ||||
| 	DefaultMergeStyle *MergeStyle `json:"default_merge_style,omitempty"` | ||||
| 	// set to `true` to archive this repository. | ||||
| } | ||||
|  | ||||
| // EditRepo edit the properties of a repository | ||||
| func (c *Client) EditRepo(owner, reponame string, opt EditRepoOption) (*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &reponame); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| @@ -429,18 +459,27 @@ func (c *Client) EditRepo(owner, reponame string, opt EditRepoOption) (*Reposito | ||||
|  | ||||
| // DeleteRepo deletes a repository of user or organization. | ||||
| func (c *Client) DeleteRepo(owner, repo string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s", owner, repo), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // MirrorSync adds a mirrored repository to the mirror sync queue. | ||||
| func (c *Client) MirrorSync(owner, repo string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/mirror-sync", owner, repo), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // GetRepoLanguages return language stats of a repo | ||||
| func (c *Client) GetRepoLanguages(owner, repo string) (map[string]int64, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	langMap := make(map[string]int64) | ||||
|  | ||||
| 	data, resp, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/languages", owner, repo), jsonHeader, nil) | ||||
| @@ -466,7 +505,11 @@ const ( | ||||
| // GetArchive get an archive of a repository by git reference | ||||
| // e.g.: ref -> master, 70b7c74b33, v1.2.1, ... | ||||
| func (c *Client) GetArchive(owner, repo, ref string, ext ArchiveType) ([]byte, *Response, error) { | ||||
| 	return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/archive/%s%s", owner, repo, url.PathEscape(ref), ext), nil, nil) | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	ref = pathEscapeSegments(ref) | ||||
| 	return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/archive/%s%s", owner, repo, ref, ext), nil, nil) | ||||
| } | ||||
|  | ||||
| // GetArchiveReader gets a `git archive` for a particular tree-ish git reference | ||||
| @@ -474,7 +517,11 @@ func (c *Client) GetArchive(owner, repo, ref string, ext ArchiveType) ([]byte, * | ||||
| // (`v1.2.1`). The archive is returned as a byte stream in a ReadCloser. It is | ||||
| // the responsibility of the client to close the reader. | ||||
| func (c *Client) GetArchiveReader(owner, repo, ref string, ext ArchiveType) (io.ReadCloser, *Response, error) { | ||||
| 	resp, err := c.doRequest("GET", fmt.Sprintf("/repos/%s/%s/archive/%s%s", owner, repo, url.PathEscape(ref), ext), nil, nil) | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	ref = pathEscapeSegments(ref) | ||||
| 	resp, err := c.doRequest("GET", fmt.Sprintf("/repos/%s/%s/archive/%s%s", owner, repo, ref, ext), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return nil, resp, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/repo_branch.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/repo_branch.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,9 +20,6 @@ type PayloadUser struct { | ||||
| 	UserName string `json:"username"` | ||||
| } | ||||
|  | ||||
| // FIXME: consider using same format as API when commits API are added. | ||||
| //        applies to PayloadCommit and PayloadCommitVerification | ||||
|  | ||||
| // PayloadCommit represents a commit | ||||
| type PayloadCommit struct { | ||||
| 	// sha1 hash of the commit | ||||
| @@ -66,6 +63,9 @@ type ListRepoBranchesOptions struct { | ||||
|  | ||||
| // ListRepoBranches list all the branches of one repository | ||||
| func (c *Client) ListRepoBranches(user, repo string, opt ListRepoBranchesOptions) ([]*Branch, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	branches := make([]*Branch, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &branches) | ||||
| @@ -74,6 +74,9 @@ func (c *Client) ListRepoBranches(user, repo string, opt ListRepoBranchesOptions | ||||
|  | ||||
| // GetRepoBranch get one branch's information of one repository | ||||
| func (c *Client) GetRepoBranch(user, repo, branch string) (*Branch, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &branch); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	b := new(Branch) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches/%s", user, repo, branch), nil, nil, &b) | ||||
| 	if err != nil { | ||||
| @@ -84,6 +87,9 @@ func (c *Client) GetRepoBranch(user, repo, branch string) (*Branch, *Response, e | ||||
|  | ||||
| // DeleteRepoBranch delete a branch in a repository | ||||
| func (c *Client) DeleteRepoBranch(user, repo, branch string) (bool, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &branch); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| @@ -118,6 +124,9 @@ func (opt CreateBranchOption) Validate() error { | ||||
|  | ||||
| // CreateBranch creates a branch for a user's repository | ||||
| func (c *Client) CreateBranch(owner, repo string, opt CreateBranchOption) (*Branch, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/repo_branch_protection.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/repo_branch_protection.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -95,6 +95,9 @@ type ListBranchProtectionsOptions struct { | ||||
|  | ||||
| // ListBranchProtections list branch protections for a repo | ||||
| func (c *Client) ListBranchProtections(owner, repo string, opt ListBranchProtectionsOptions) ([]*BranchProtection, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -107,6 +110,9 @@ func (c *Client) ListBranchProtections(owner, repo string, opt ListBranchProtect | ||||
|  | ||||
| // GetBranchProtection gets a branch protection | ||||
| func (c *Client) GetBranchProtection(owner, repo, name string) (*BranchProtection, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &name); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -117,6 +123,9 @@ func (c *Client) GetBranchProtection(owner, repo, name string) (*BranchProtectio | ||||
|  | ||||
| // CreateBranchProtection creates a branch protection for a repo | ||||
| func (c *Client) CreateBranchProtection(owner, repo string, opt CreateBranchProtectionOption) (*BranchProtection, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -131,6 +140,9 @@ func (c *Client) CreateBranchProtection(owner, repo string, opt CreateBranchProt | ||||
|  | ||||
| // EditBranchProtection edits a branch protection for a repo | ||||
| func (c *Client) EditBranchProtection(owner, repo, name string, opt EditBranchProtectionOption) (*BranchProtection, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &name); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -145,6 +157,9 @@ func (c *Client) EditBranchProtection(owner, repo, name string, opt EditBranchPr | ||||
|  | ||||
| // DeleteBranchProtection deletes a branch protection for a repo | ||||
| func (c *Client) DeleteBranchProtection(owner, repo, name string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &name); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										39
									
								
								vendor/code.gitea.io/sdk/gitea/repo_collaborator.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										39
									
								
								vendor/code.gitea.io/sdk/gitea/repo_collaborator.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,3 +1,4 @@ | ||||
| // Copyright 2021 The Gitea Authors. All rights reserved. | ||||
| // Copyright 2016 The Gogs Authors. All rights reserved. | ||||
| // Use of this source code is governed by a MIT-style | ||||
| // license that can be found in the LICENSE file. | ||||
| @@ -17,6 +18,9 @@ type ListCollaboratorsOptions struct { | ||||
|  | ||||
| // ListCollaborators list a repository's collaborators | ||||
| func (c *Client) ListCollaborators(user, repo string, opt ListCollaboratorsOptions) ([]*User, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	collaborators := make([]*User, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", | ||||
| @@ -27,6 +31,9 @@ func (c *Client) ListCollaborators(user, repo string, opt ListCollaboratorsOptio | ||||
|  | ||||
| // IsCollaborator check if a user is a collaborator of a repository | ||||
| func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &collaborator); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| 	status, resp, err := c.getStatusCode("GET", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return false, resp, err | ||||
| @@ -78,6 +85,9 @@ func (opt AddCollaboratorOption) Validate() error { | ||||
|  | ||||
| // AddCollaborator add some user as a collaborator of a repository | ||||
| func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollaboratorOption) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &collaborator); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -91,7 +101,36 @@ func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollabo | ||||
|  | ||||
| // DeleteCollaborator remove a collaborator from a repository | ||||
| func (c *Client) DeleteCollaborator(user, repo, collaborator string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &collaborator); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", | ||||
| 		fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // GetReviewers return all users that can be requested to review in this repo | ||||
| func (c *Client) GetReviewers(user, repo string) ([]*User, *Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	reviewers := make([]*User, 0, 5) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/reviewers", user, repo), nil, nil, &reviewers) | ||||
| 	return reviewers, resp, err | ||||
| } | ||||
|  | ||||
| // GetAssignees return all users that have write access and can be assigned to issues | ||||
| func (c *Client) GetAssignees(user, repo string) ([]*User, *Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	assignees := make([]*User, 0, 5) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/assignees", user, repo), nil, nil, &assignees) | ||||
| 	return assignees, resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/code.gitea.io/sdk/gitea/repo_commit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/code.gitea.io/sdk/gitea/repo_commit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -63,6 +63,9 @@ type CommitAffectedFiles struct { | ||||
|  | ||||
| // GetSingleCommit returns a single commit | ||||
| func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &commitID); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	commit := new(Commit) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/commits/%s", user, repo, commitID), nil, nil, &commit) | ||||
| 	return commit, resp, err | ||||
| @@ -86,6 +89,9 @@ func (opt *ListCommitOptions) QueryEncode() string { | ||||
|  | ||||
| // ListRepoCommits return list of commits from a repo | ||||
| func (c *Client) ListRepoCommits(user, repo string, opt ListCommitOptions) ([]*Commit, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/commits", user, repo)) | ||||
| 	opt.setDefaults() | ||||
| 	commits := make([]*Commit, 0, opt.PageSize) | ||||
|   | ||||
							
								
								
									
										32
									
								
								vendor/code.gitea.io/sdk/gitea/repo_file.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								vendor/code.gitea.io/sdk/gitea/repo_file.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -116,19 +116,12 @@ type FileDeleteResponse struct { | ||||
| 	Verification *PayloadCommitVerification `json:"verification"` | ||||
| } | ||||
|  | ||||
| // pathEscapeSegments escapes segments of a path while not escaping forward slash | ||||
| func pathEscapeSegments(path string) string { | ||||
| 	slice := strings.Split(path, "/") | ||||
| 	for index := range slice { | ||||
| 		slice[index] = url.PathEscape(slice[index]) | ||||
| 	} | ||||
| 	escapedPath := strings.Join(slice, "/") | ||||
| 	return escapedPath | ||||
| } | ||||
|  | ||||
| // GetFile downloads a file of repository, ref can be branch/tag/commit. | ||||
| // e.g.: ref -> master, filepath -> README.md (no leading slash) | ||||
| func (c *Client) GetFile(owner, repo, ref, filepath string) ([]byte, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	filepath = pathEscapeSegments(filepath) | ||||
| 	if c.checkServerVersionGreaterThanOrEqual(version1_14_0) != nil { | ||||
| 		ref = pathEscapeSegments(ref) | ||||
| @@ -166,17 +159,23 @@ func (c *Client) ListContents(owner, repo, ref, filepath string) ([]*ContentsRes | ||||
| } | ||||
|  | ||||
| func (c *Client) getDirOrFileContents(owner, repo, ref, filepath string) ([]byte, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	filepath = pathEscapeSegments(strings.TrimPrefix(filepath, "/")) | ||||
| 	return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/contents/%s?ref=%s", owner, repo, filepath, url.QueryEscape(ref)), jsonHeader, nil) | ||||
| } | ||||
|  | ||||
| // CreateFile create a file in a repository | ||||
| func (c *Client) CreateFile(owner, repo, filepath string, opt CreateFileOptions) (*FileResponse, *Response, error) { | ||||
| 	filepath = pathEscapeSegments(filepath) | ||||
| 	var err error | ||||
| 	if opt.BranchName, err = c.setDefaultBranchForOldVersions(owner, repo, opt.BranchName); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	filepath = pathEscapeSegments(filepath) | ||||
|  | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| @@ -189,12 +188,16 @@ func (c *Client) CreateFile(owner, repo, filepath string, opt CreateFileOptions) | ||||
|  | ||||
| // UpdateFile update a file in a repository | ||||
| func (c *Client) UpdateFile(owner, repo, filepath string, opt UpdateFileOptions) (*FileResponse, *Response, error) { | ||||
| 	filepath = pathEscapeSegments(filepath) | ||||
| 	var err error | ||||
| 	if opt.BranchName, err = c.setDefaultBranchForOldVersions(owner, repo, opt.BranchName); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
|  | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	filepath = pathEscapeSegments(filepath) | ||||
|  | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| @@ -206,11 +209,14 @@ func (c *Client) UpdateFile(owner, repo, filepath string, opt UpdateFileOptions) | ||||
|  | ||||
| // DeleteFile delete a file from repository | ||||
| func (c *Client) DeleteFile(owner, repo, filepath string, opt DeleteFileOptions) (*Response, error) { | ||||
| 	filepath = pathEscapeSegments(filepath) | ||||
| 	var err error | ||||
| 	if opt.BranchName, err = c.setDefaultBranchForOldVersions(owner, repo, opt.BranchName); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	filepath = pathEscapeSegments(filepath) | ||||
|  | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/code.gitea.io/sdk/gitea/repo_key.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/code.gitea.io/sdk/gitea/repo_key.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -46,6 +46,9 @@ func (opt *ListDeployKeysOptions) QueryEncode() string { | ||||
|  | ||||
| // ListDeployKeys list all the deploy keys of one repository | ||||
| func (c *Client) ListDeployKeys(user, repo string, opt ListDeployKeysOptions) ([]*DeployKey, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/keys", user, repo)) | ||||
| 	opt.setDefaults() | ||||
| 	link.RawQuery = opt.QueryEncode() | ||||
| @@ -56,6 +59,9 @@ func (c *Client) ListDeployKeys(user, repo string, opt ListDeployKeysOptions) ([ | ||||
|  | ||||
| // GetDeployKey get one deploy key with key id | ||||
| func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	key := new(DeployKey) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys/%d", user, repo, keyID), nil, nil, &key) | ||||
| 	return key, resp, err | ||||
| @@ -63,6 +69,9 @@ func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, *Resp | ||||
|  | ||||
| // CreateDeployKey options when create one deploy key | ||||
| func (c *Client) CreateDeployKey(user, repo string, opt CreateKeyOption) (*DeployKey, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| @@ -74,6 +83,9 @@ func (c *Client) CreateDeployKey(user, repo string, opt CreateKeyOption) (*Deplo | ||||
|  | ||||
| // DeleteDeployKey delete deploy key with key id | ||||
| func (c *Client) DeleteDeployKey(owner, repo string, keyID int64) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/keys/%d", owner, repo, keyID), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/code.gitea.io/sdk/gitea/repo_migrate.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/code.gitea.io/sdk/gitea/repo_migrate.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -47,6 +47,8 @@ type MigrateRepoOption struct { | ||||
| 	PullRequests   bool           `json:"pull_requests"` | ||||
| 	Releases       bool           `json:"releases"` | ||||
| 	MirrorInterval string         `json:"mirror_interval"` | ||||
| 	LFS            bool           `json:"lfs"` | ||||
| 	LFSEndpoint    string         `json:"lfs_endpoint"` | ||||
| } | ||||
|  | ||||
| // Validate the MigrateRepoOption struct | ||||
|   | ||||
							
								
								
									
										9
									
								
								vendor/code.gitea.io/sdk/gitea/repo_refs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								vendor/code.gitea.io/sdk/gitea/repo_refs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -27,7 +27,11 @@ type GitObject struct { | ||||
|  | ||||
| // GetRepoRef get one ref's information of one repository | ||||
| func (c *Client) GetRepoRef(user, repo, ref string) (*Reference, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	ref = strings.TrimPrefix(ref, "refs/") | ||||
| 	ref = pathEscapeSegments(ref) | ||||
| 	r := new(Reference) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", user, repo, ref), nil, nil, &r) | ||||
| 	if _, ok := err.(*json.UnmarshalTypeError); ok { | ||||
| @@ -42,7 +46,12 @@ func (c *Client) GetRepoRef(user, repo, ref string) (*Reference, *Response, erro | ||||
|  | ||||
| // GetRepoRefs get list of ref's information of one repository | ||||
| func (c *Client) GetRepoRefs(user, repo, ref string) ([]*Reference, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	ref = strings.TrimPrefix(ref, "refs/") | ||||
| 	ref = pathEscapeSegments(ref) | ||||
|  | ||||
| 	data, resp, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", user, repo, ref), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return nil, resp, err | ||||
|   | ||||
							
								
								
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/repo_stars.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/code.gitea.io/sdk/gitea/repo_stars.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -16,6 +16,9 @@ type ListStargazersOptions struct { | ||||
|  | ||||
| // ListRepoStargazers list a repository's stargazers | ||||
| func (c *Client) ListRepoStargazers(user, repo string, opt ListStargazersOptions) ([]*User, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	stargazers := make([]*User, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/stargazers?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &stargazers) | ||||
| @@ -24,6 +27,9 @@ func (c *Client) ListRepoStargazers(user, repo string, opt ListStargazersOptions | ||||
|  | ||||
| // GetStarredRepos returns the repos that the given user has starred | ||||
| func (c *Client) GetStarredRepos(user string) ([]*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	repos := make([]*Repository, 0, 10) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/starred", user), jsonHeader, nil, &repos) | ||||
| 	return repos, resp, err | ||||
| @@ -38,6 +44,9 @@ func (c *Client) GetMyStarredRepos() ([]*Repository, *Response, error) { | ||||
|  | ||||
| // IsRepoStarring returns whether the authenticated user has starred the repo or not | ||||
| func (c *Client) IsRepoStarring(user, repo string) (bool, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("GET", fmt.Sprintf("/user/starred/%s/%s", user, repo), jsonHeader, nil) | ||||
| 	if resp != nil { | ||||
| 		switch resp.StatusCode { | ||||
| @@ -54,6 +63,9 @@ func (c *Client) IsRepoStarring(user, repo string) (bool, *Response, error) { | ||||
|  | ||||
| // StarRepo star specified repo as the authenticated user | ||||
| func (c *Client) StarRepo(user, repo string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("PUT", fmt.Sprintf("/user/starred/%s/%s", user, repo), jsonHeader, nil) | ||||
| 	if resp != nil { | ||||
| 		switch resp.StatusCode { | ||||
| @@ -68,6 +80,9 @@ func (c *Client) StarRepo(user, repo string) (*Response, error) { | ||||
|  | ||||
| // UnStarRepo remove star to specified repo as the authenticated user | ||||
| func (c *Client) UnStarRepo(user, repo string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/user/starred/%s/%s", user, repo), jsonHeader, nil) | ||||
| 	if resp != nil { | ||||
| 		switch resp.StatusCode { | ||||
|   | ||||
							
								
								
									
										90
									
								
								vendor/code.gitea.io/sdk/gitea/repo_tag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										90
									
								
								vendor/code.gitea.io/sdk/gitea/repo_tag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -5,18 +5,39 @@ | ||||
| package gitea | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| ) | ||||
|  | ||||
| // Tag represents a repository tag | ||||
| type Tag struct { | ||||
| 	Name       string      `json:"name"` | ||||
| 	Message    string      `json:"message"` | ||||
| 	ID         string      `json:"id"` | ||||
| 	Commit     *CommitMeta `json:"commit"` | ||||
| 	ZipballURL string      `json:"zipball_url"` | ||||
| 	TarballURL string      `json:"tarball_url"` | ||||
| } | ||||
|  | ||||
| // AnnotatedTag represents an annotated tag | ||||
| type AnnotatedTag struct { | ||||
| 	Tag          string                     `json:"tag"` | ||||
| 	SHA          string                     `json:"sha"` | ||||
| 	URL          string                     `json:"url"` | ||||
| 	Message      string                     `json:"message"` | ||||
| 	Tagger       *CommitUser                `json:"tagger"` | ||||
| 	Object       *AnnotatedTagObject        `json:"object"` | ||||
| 	Verification *PayloadCommitVerification `json:"verification"` | ||||
| } | ||||
|  | ||||
| // AnnotatedTagObject contains meta information of the tag object | ||||
| type AnnotatedTagObject struct { | ||||
| 	Type string `json:"type"` | ||||
| 	URL  string `json:"url"` | ||||
| 	SHA  string `json:"sha"` | ||||
| } | ||||
|  | ||||
| // ListRepoTagsOptions options for listing a repository's tags | ||||
| type ListRepoTagsOptions struct { | ||||
| 	ListOptions | ||||
| @@ -24,14 +45,81 @@ type ListRepoTagsOptions struct { | ||||
|  | ||||
| // ListRepoTags list all the branches of one repository | ||||
| func (c *Client) ListRepoTags(user, repo string, opt ListRepoTagsOptions) ([]*Tag, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	tags := make([]*Tag, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/tags?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &tags) | ||||
| 	return tags, resp, err | ||||
| } | ||||
|  | ||||
| // GetTag get the tag of a repository | ||||
| func (c *Client) GetTag(user, repo, tag string) (*Tag, *Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &tag); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	t := new(Tag) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/tags/%s", user, repo, tag), nil, nil, &t) | ||||
| 	return t, resp, err | ||||
| } | ||||
|  | ||||
| // GetAnnotatedTag get the tag object of an annotated tag (not lightweight tags) of a repository | ||||
| func (c *Client) GetAnnotatedTag(user, repo, sha string) (*AnnotatedTag, *Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &sha); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	t := new(AnnotatedTag) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/tags/%s", user, repo, sha), nil, nil, &t) | ||||
| 	return t, resp, err | ||||
| } | ||||
|  | ||||
| // CreateTagOption options when creating a tag | ||||
| type CreateTagOption struct { | ||||
| 	TagName string `json:"tag_name"` | ||||
| 	Message string `json:"message"` | ||||
| 	Target  string `json:"target"` | ||||
| } | ||||
|  | ||||
| // Validate validates CreateTagOption | ||||
| func (opt CreateTagOption) Validate() error { | ||||
| 	if len(opt.TagName) == 0 { | ||||
| 		return fmt.Errorf("TagName is required") | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // CreateTag create a new git tag in a repository | ||||
| func (c *Client) CreateTag(user, repo string, opt CreateTagOption) (*Tag, *Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	t := new(Tag) | ||||
| 	resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/tags", user, repo), jsonHeader, bytes.NewReader(body), &t) | ||||
| 	return t, resp, err | ||||
| } | ||||
|  | ||||
| // DeleteTag deletes a tag from a repository, if no release refers to it | ||||
| func (c *Client) DeleteTag(user, repo string, tag string) (*Response, error) { | ||||
| func (c *Client) DeleteTag(user, repo, tag string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &tag); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_14_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										65
									
								
								vendor/code.gitea.io/sdk/gitea/repo_team.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								vendor/code.gitea.io/sdk/gitea/repo_team.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| // Copyright 2021 The Gitea Authors. All rights reserved. | ||||
| // Use of this source code is governed by a MIT-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package gitea | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| ) | ||||
|  | ||||
| // GetRepoTeams return teams from a repository | ||||
| func (c *Client) GetRepoTeams(user, repo string) ([]*Team, *Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	teams := make([]*Team, 0, 5) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/teams", user, repo), nil, nil, &teams) | ||||
| 	return teams, resp, err | ||||
| } | ||||
|  | ||||
| // AddRepoTeam add a team to a repository | ||||
| func (c *Client) AddRepoTeam(user, repo, team string) (*Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &team); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/teams/%s", user, repo, team), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // RemoveRepoTeam delete a team from a repository | ||||
| func (c *Client) RemoveRepoTeam(user, repo, team string) (*Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &team); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/teams/%s", user, repo, team), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // CheckRepoTeam check if team is assigned to repo by name and return it. | ||||
| // If not assigned, it will return nil. | ||||
| func (c *Client) CheckRepoTeam(user, repo, team string) (*Team, *Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &team); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	t := new(Team) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/teams/%s", user, repo, team), nil, nil, &t) | ||||
| 	if resp != nil && resp.StatusCode == http.StatusNotFound { | ||||
| 		// if not found it's not an error, it indicates it's not assigned | ||||
| 		return nil, resp, nil | ||||
| 	} | ||||
| 	return t, resp, err | ||||
| } | ||||
							
								
								
									
										65
									
								
								vendor/code.gitea.io/sdk/gitea/repo_template.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								vendor/code.gitea.io/sdk/gitea/repo_template.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| // Copyright 2021 The Gitea Authors. All rights reserved. | ||||
| // Use of this source code is governed by a MIT-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package gitea | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| ) | ||||
|  | ||||
| // CreateRepoFromTemplateOption options when creating repository using a template | ||||
| type CreateRepoFromTemplateOption struct { | ||||
| 	// Owner is the organization or person who will own the new repository | ||||
| 	Owner string `json:"owner"` | ||||
| 	// Name of the repository to create | ||||
| 	Name string `json:"name"` | ||||
| 	// Description of the repository to create | ||||
| 	Description string `json:"description"` | ||||
| 	// Private is whether the repository is private | ||||
| 	Private bool `json:"private"` | ||||
| 	// GitContent include git content of default branch in template repo | ||||
| 	GitContent bool `json:"git_content"` | ||||
| 	// Topics include topics of template repo | ||||
| 	Topics bool `json:"topics"` | ||||
| 	// GitHooks include git hooks of template repo | ||||
| 	GitHooks bool `json:"git_hooks"` | ||||
| 	// Webhooks include webhooks of template repo | ||||
| 	Webhooks bool `json:"webhooks"` | ||||
| 	// Avatar include avatar of the template repo | ||||
| 	Avatar bool `json:"avatar"` | ||||
| 	// Labels include labels of template repo | ||||
| 	Labels bool `json:"labels"` | ||||
| } | ||||
|  | ||||
| // Validate validates CreateRepoFromTemplateOption | ||||
| func (opt CreateRepoFromTemplateOption) Validate() error { | ||||
| 	if len(opt.Owner) == 0 { | ||||
| 		return fmt.Errorf("field Owner is required") | ||||
| 	} | ||||
| 	if len(opt.Name) == 0 { | ||||
| 		return fmt.Errorf("field Name is required") | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // CreateRepoFromTemplate create a repository using a template | ||||
| func (c *Client) CreateRepoFromTemplate(templateOwner, templateRepo string, opt CreateRepoFromTemplateOption) (*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&templateOwner, &templateRepo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
|  | ||||
| 	if err := opt.Validate(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
|  | ||||
| 	repo := new(Repository) | ||||
| 	resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/generate", templateOwner, templateRepo), jsonHeader, bytes.NewReader(body), &repo) | ||||
| 	return repo, resp, err | ||||
| } | ||||
							
								
								
									
										14
									
								
								vendor/code.gitea.io/sdk/gitea/repo_topics.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								vendor/code.gitea.io/sdk/gitea/repo_topics.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -22,6 +22,9 @@ type topicsList struct { | ||||
|  | ||||
| // ListRepoTopics list all repository's topics | ||||
| func (c *Client) ListRepoTopics(user, repo string, opt ListRepoTopicsOptions) ([]string, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
|  | ||||
| 	list := new(topicsList) | ||||
| @@ -34,9 +37,10 @@ func (c *Client) ListRepoTopics(user, repo string, opt ListRepoTopicsOptions) ([ | ||||
|  | ||||
| // SetRepoTopics replaces the list of repo's topics | ||||
| func (c *Client) SetRepoTopics(user, repo string, list []string) (*Response, error) { | ||||
|  | ||||
| 	if err := escapeValidatePathSegments(&user, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	l := topicsList{Topics: list} | ||||
|  | ||||
| 	body, err := json.Marshal(&l) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -47,12 +51,18 @@ func (c *Client) SetRepoTopics(user, repo string, list []string) (*Response, err | ||||
|  | ||||
| // AddRepoTopic adds a topic to a repo's topics list | ||||
| func (c *Client) AddRepoTopic(user, repo, topic string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &topic); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/topics/%s", user, repo, topic), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // DeleteRepoTopic deletes a topic from repo's topics list | ||||
| func (c *Client) DeleteRepoTopic(user, repo, topic string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &topic); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/topics/%s", user, repo, topic), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/repo_transfer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/repo_transfer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,6 +20,9 @@ type TransferRepoOption struct { | ||||
|  | ||||
| // TransferRepo transfers the ownership of a repository | ||||
| func (c *Client) TransferRepo(owner, reponame string, opt TransferRepoOption) (*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &reponame); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/repo_tree.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/repo_tree.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -31,6 +31,9 @@ type GitTreeResponse struct { | ||||
| // GetTrees downloads a file of repository, ref can be branch/tag/commit. | ||||
| // e.g.: ref -> master, tree -> macaron.go(no leading slash) | ||||
| func (c *Client) GetTrees(user, repo, ref string, recursive bool) (*GitTreeResponse, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user, &repo, &ref); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	trees := new(GitTreeResponse) | ||||
| 	var path = fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref) | ||||
| 	if recursive { | ||||
|   | ||||
							
								
								
									
										24
									
								
								vendor/code.gitea.io/sdk/gitea/repo_watch.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								vendor/code.gitea.io/sdk/gitea/repo_watch.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -22,6 +22,9 @@ type WatchInfo struct { | ||||
|  | ||||
| // GetWatchedRepos list all the watched repos of user | ||||
| func (c *Client) GetWatchedRepos(user string) ([]*Repository, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	repos := make([]*Repository, 0, 10) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/subscriptions", user), nil, nil, &repos) | ||||
| 	return repos, resp, err | ||||
| @@ -35,8 +38,11 @@ func (c *Client) GetMyWatchedRepos() ([]*Repository, *Response, error) { | ||||
| } | ||||
|  | ||||
| // CheckRepoWatch check if the current user is watching a repo | ||||
| func (c *Client) CheckRepoWatch(repoUser, repoName string) (bool, *Response, error) { | ||||
| 	status, resp, err := c.getStatusCode("GET", fmt.Sprintf("/repos/%s/%s/subscription", repoUser, repoName), nil, nil) | ||||
| func (c *Client) CheckRepoWatch(owner, repo string) (bool, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return false, nil, err | ||||
| 	} | ||||
| 	status, resp, err := c.getStatusCode("GET", fmt.Sprintf("/repos/%s/%s/subscription", owner, repo), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return false, resp, err | ||||
| 	} | ||||
| @@ -51,8 +57,11 @@ func (c *Client) CheckRepoWatch(repoUser, repoName string) (bool, *Response, err | ||||
| } | ||||
|  | ||||
| // WatchRepo start to watch a repository | ||||
| func (c *Client) WatchRepo(repoUser, repoName string) (*Response, error) { | ||||
| 	status, resp, err := c.getStatusCode("PUT", fmt.Sprintf("/repos/%s/%s/subscription", repoUser, repoName), nil, nil) | ||||
| func (c *Client) WatchRepo(owner, repo string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	status, resp, err := c.getStatusCode("PUT", fmt.Sprintf("/repos/%s/%s/subscription", owner, repo), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return resp, err | ||||
| 	} | ||||
| @@ -63,8 +72,11 @@ func (c *Client) WatchRepo(repoUser, repoName string) (*Response, error) { | ||||
| } | ||||
|  | ||||
| // UnWatchRepo stop to watch a repository | ||||
| func (c *Client) UnWatchRepo(repoUser, repoName string) (*Response, error) { | ||||
| 	status, resp, err := c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/subscription", repoUser, repoName), nil, nil) | ||||
| func (c *Client) UnWatchRepo(owner, repo string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	status, resp, err := c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/subscription", owner, repo), nil, nil) | ||||
| 	if err != nil { | ||||
| 		return resp, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										10
									
								
								vendor/code.gitea.io/sdk/gitea/settings.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/code.gitea.io/sdk/gitea/settings.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -8,13 +8,17 @@ package gitea | ||||
| type GlobalUISettings struct { | ||||
| 	DefaultTheme     string   `json:"default_theme"` | ||||
| 	AllowedReactions []string `json:"allowed_reactions"` | ||||
| 	CustomEmojis     []string `json:"custom_emojis"` | ||||
| } | ||||
|  | ||||
| // GlobalRepoSettings represent the global repository settings of a gitea instance witch is exposed by API | ||||
| type GlobalRepoSettings struct { | ||||
| 	MirrorsDisabled    bool `json:"mirrors_disabled"` | ||||
| 	HTTPGitDisabled    bool `json:"http_git_disabled"` | ||||
| 	MigrationsDisabled bool `json:"migrations_disabled"` | ||||
| 	MirrorsDisabled      bool `json:"mirrors_disabled"` | ||||
| 	HTTPGitDisabled      bool `json:"http_git_disabled"` | ||||
| 	MigrationsDisabled   bool `json:"migrations_disabled"` | ||||
| 	StarsDisabled        bool `json:"stars_disabled"` | ||||
| 	TimeTrackingDisabled bool `json:"time_tracking_disabled"` | ||||
| 	LFSDisabled          bool `json:"lfs_disabled"` | ||||
| } | ||||
|  | ||||
| // GlobalAPISettings contains global api settings exposed by it | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/code.gitea.io/sdk/gitea/status.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/code.gitea.io/sdk/gitea/status.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -8,6 +8,7 @@ import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"net/url" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| @@ -51,12 +52,15 @@ type CreateStatusOption struct { | ||||
|  | ||||
| // CreateStatus creates a new Status for a given Commit | ||||
| func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption) (*Status, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opts) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	status := new(Status) | ||||
| 	resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), jsonHeader, bytes.NewReader(body), status) | ||||
| 	resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, url.QueryEscape(sha)), jsonHeader, bytes.NewReader(body), status) | ||||
| 	return status, resp, err | ||||
| } | ||||
|  | ||||
| @@ -67,6 +71,9 @@ type ListStatusesOption struct { | ||||
|  | ||||
| // ListStatuses returns all statuses for a given Commit by ref | ||||
| func (c *Client) ListStatuses(owner, repo, ref string, opt ListStatusesOption) ([]*Status, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &ref); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	statuses := make([]*Status, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/statuses?%s", owner, repo, ref, opt.getURLQuery().Encode()), jsonHeader, nil, &statuses) | ||||
| @@ -86,6 +93,9 @@ type CombinedStatus struct { | ||||
|  | ||||
| // GetCombinedStatus returns the CombinedStatus for a given Commit | ||||
| func (c *Client) GetCombinedStatus(owner, repo, ref string) (*CombinedStatus, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&owner, &repo, &ref); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	status := new(CombinedStatus) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/status", owner, repo, ref), jsonHeader, nil, status) | ||||
|  | ||||
|   | ||||
							
								
								
									
										53
									
								
								vendor/code.gitea.io/sdk/gitea/user.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										53
									
								
								vendor/code.gitea.io/sdk/gitea/user.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -6,6 +6,8 @@ package gitea | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| @@ -23,13 +25,37 @@ type User struct { | ||||
| 	// User locale | ||||
| 	Language string `json:"language"` | ||||
| 	// Is the user an administrator | ||||
| 	IsAdmin   bool      `json:"is_admin"` | ||||
| 	LastLogin time.Time `json:"last_login,omitempty"` | ||||
| 	Created   time.Time `json:"created,omitempty"` | ||||
| 	IsAdmin bool `json:"is_admin"` | ||||
| 	// Date and Time of last login | ||||
| 	LastLogin time.Time `json:"last_login"` | ||||
| 	// Date and Time of user creation | ||||
| 	Created time.Time `json:"created"` | ||||
| 	// Is user restricted | ||||
| 	Restricted bool `json:"restricted"` | ||||
| 	// Is user active | ||||
| 	IsActive bool `json:"active"` | ||||
| 	// Is user login prohibited | ||||
| 	ProhibitLogin bool `json:"prohibit_login"` | ||||
| 	// the user's location | ||||
| 	Location string `json:"location"` | ||||
| 	// the user's website | ||||
| 	Website string `json:"website"` | ||||
| 	// the user's description | ||||
| 	Description string `json:"description"` | ||||
| 	// User visibility level option | ||||
| 	Visibility VisibleType `json:"visibility"` | ||||
|  | ||||
| 	// user counts | ||||
| 	FollowerCount    int `json:"followers_count"` | ||||
| 	FollowingCount   int `json:"following_count"` | ||||
| 	StarredRepoCount int `json:"starred_repos_count"` | ||||
| } | ||||
|  | ||||
| // GetUserInfo get user info by user's name | ||||
| func (c *Client) GetUserInfo(user string) (*User, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	u := new(User) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s", user), nil, nil, u) | ||||
| 	return u, resp, err | ||||
| @@ -41,3 +67,24 @@ func (c *Client) GetMyUserInfo() (*User, *Response, error) { | ||||
| 	resp, err := c.getParsedResponse("GET", "/user", nil, nil, u) | ||||
| 	return u, resp, err | ||||
| } | ||||
|  | ||||
| // GetUserByID returns user by a given user ID | ||||
| func (c *Client) GetUserByID(id int64) (*User, *Response, error) { | ||||
| 	if id < 0 { | ||||
| 		return nil, nil, fmt.Errorf("invalid user id %d", id) | ||||
| 	} | ||||
|  | ||||
| 	query := make(url.Values) | ||||
| 	query.Add("uid", strconv.FormatInt(id, 10)) | ||||
| 	users, resp, err := c.searchUsers(query.Encode()) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return nil, resp, err | ||||
| 	} | ||||
|  | ||||
| 	if len(users) == 1 { | ||||
| 		return users[0], resp, err | ||||
| 	} | ||||
|  | ||||
| 	return nil, resp, fmt.Errorf("user not found with id %d", id) | ||||
| } | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/code.gitea.io/sdk/gitea/user_app.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/code.gitea.io/sdk/gitea/user_app.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -9,6 +9,7 @@ import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"net/url" | ||||
| 	"reflect" | ||||
| ) | ||||
|  | ||||
| @@ -35,7 +36,7 @@ func (c *Client) ListAccessTokens(opts ListAccessTokensOptions) ([]*AccessToken, | ||||
| 	} | ||||
| 	opts.setDefaults() | ||||
| 	tokens := make([]*AccessToken, 0, opts.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/tokens?%s", username, opts.getURLQuery().Encode()), jsonHeader, nil, &tokens) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/tokens?%s", url.PathEscape(username), opts.getURLQuery().Encode()), jsonHeader, nil, &tokens) | ||||
| 	return tokens, resp, err | ||||
| } | ||||
|  | ||||
| @@ -57,7 +58,7 @@ func (c *Client) CreateAccessToken(opt CreateAccessTokenOption) (*AccessToken, * | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	t := new(AccessToken) | ||||
| 	resp, err := c.getParsedResponse("POST", fmt.Sprintf("/users/%s/tokens", username), jsonHeader, bytes.NewReader(body), t) | ||||
| 	resp, err := c.getParsedResponse("POST", fmt.Sprintf("/users/%s/tokens", url.PathEscape(username)), jsonHeader, bytes.NewReader(body), t) | ||||
| 	return t, resp, err | ||||
| } | ||||
|  | ||||
| @@ -84,6 +85,6 @@ func (c *Client) DeleteAccessToken(value interface{}) (*Response, error) { | ||||
| 		return nil, fmt.Errorf("only string and int64 supported") | ||||
| 	} | ||||
|  | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/users/%s/tokens/%s", username, token), jsonHeader, nil) | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/users/%s/tokens/%s", url.PathEscape(username), url.PathEscape(token)), jsonHeader, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										20
									
								
								vendor/code.gitea.io/sdk/gitea/user_follow.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								vendor/code.gitea.io/sdk/gitea/user_follow.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -21,6 +21,9 @@ func (c *Client) ListMyFollowers(opt ListFollowersOptions) ([]*User, *Response, | ||||
|  | ||||
| // ListFollowers list all the followers of one user | ||||
| func (c *Client) ListFollowers(user string, opt ListFollowersOptions) ([]*User, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	users := make([]*User, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/followers?%s", user, opt.getURLQuery().Encode()), nil, nil, &users) | ||||
| @@ -42,6 +45,9 @@ func (c *Client) ListMyFollowing(opt ListFollowingOptions) ([]*User, *Response, | ||||
|  | ||||
| // ListFollowing list all the users the user followed | ||||
| func (c *Client) ListFollowing(user string, opt ListFollowingOptions) ([]*User, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	users := make([]*User, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/following?%s", user, opt.getURLQuery().Encode()), nil, nil, &users) | ||||
| @@ -50,24 +56,38 @@ func (c *Client) ListFollowing(user string, opt ListFollowingOptions) ([]*User, | ||||
|  | ||||
| // IsFollowing if current user followed the target | ||||
| func (c *Client) IsFollowing(target string) (bool, *Response) { | ||||
| 	if err := escapeValidatePathSegments(&target); err != nil { | ||||
| 		// ToDo return err | ||||
| 		return false, nil | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("GET", fmt.Sprintf("/user/following/%s", target), nil, nil) | ||||
| 	return err == nil, resp | ||||
| } | ||||
|  | ||||
| // IsUserFollowing if the user followed the target | ||||
| func (c *Client) IsUserFollowing(user, target string) (bool, *Response) { | ||||
| 	if err := escapeValidatePathSegments(&user, &target); err != nil { | ||||
| 		// ToDo return err | ||||
| 		return false, nil | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("GET", fmt.Sprintf("/users/%s/following/%s", user, target), nil, nil) | ||||
| 	return err == nil, resp | ||||
| } | ||||
|  | ||||
| // Follow set current user follow the target | ||||
| func (c *Client) Follow(target string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&target); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("PUT", fmt.Sprintf("/user/following/%s", target), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|  | ||||
| // Unfollow set current user unfollow the target | ||||
| func (c *Client) Unfollow(target string) (*Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&target); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/user/following/%s", target), nil, nil) | ||||
| 	return resp, err | ||||
| } | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/user_gpgkey.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/user_gpgkey.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -40,6 +40,9 @@ type ListGPGKeysOptions struct { | ||||
|  | ||||
| // ListGPGKeys list all the GPG keys of the user | ||||
| func (c *Client) ListGPGKeys(user string, opt ListGPGKeysOptions) ([]*GPGKey, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	keys := make([]*GPGKey, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/gpg_keys?%s", user, opt.getURLQuery().Encode()), nil, nil, &keys) | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/user_key.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/code.gitea.io/sdk/gitea/user_key.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -31,6 +31,9 @@ type ListPublicKeysOptions struct { | ||||
|  | ||||
| // ListPublicKeys list all the public keys of the user | ||||
| func (c *Client) ListPublicKeys(user string, opt ListPublicKeysOptions) ([]*PublicKey, *Response, error) { | ||||
| 	if err := escapeValidatePathSegments(&user); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	opt.setDefaults() | ||||
| 	keys := make([]*PublicKey, 0, opt.PageSize) | ||||
| 	resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/keys?%s", user, opt.getURLQuery().Encode()), nil, nil, &keys) | ||||
|   | ||||
							
								
								
									
										10
									
								
								vendor/code.gitea.io/sdk/gitea/user_search.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/code.gitea.io/sdk/gitea/user_search.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -34,11 +34,15 @@ func (opt *SearchUsersOption) QueryEncode() string { | ||||
| 	return query.Encode() | ||||
| } | ||||
|  | ||||
| // SearchUsers finds users by query | ||||
| func (c *Client) SearchUsers(opt SearchUsersOption) ([]*User, *Response, error) { | ||||
| func (c *Client) searchUsers(rawQuery string) ([]*User, *Response, error) { | ||||
| 	link, _ := url.Parse("/users/search") | ||||
| 	link.RawQuery = opt.QueryEncode() | ||||
| 	link.RawQuery = rawQuery | ||||
| 	userResp := new(searchUsersResponse) | ||||
| 	resp, err := c.getParsedResponse("GET", link.String(), nil, nil, &userResp) | ||||
| 	return userResp.Users, resp, err | ||||
| } | ||||
|  | ||||
| // SearchUsers finds users by query | ||||
| func (c *Client) SearchUsers(opt SearchUsersOption) ([]*User, *Response, error) { | ||||
| 	return c.searchUsers(opt.QueryEncode()) | ||||
| } | ||||
|   | ||||
							
								
								
									
										62
									
								
								vendor/code.gitea.io/sdk/gitea/user_settings.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								vendor/code.gitea.io/sdk/gitea/user_settings.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| // Copyright 2021 The Gitea Authors. All rights reserved. | ||||
| // Use of this source code is governed by a MIT-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package gitea | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| ) | ||||
|  | ||||
| // UserSettings represents user settings | ||||
| type UserSettings struct { | ||||
| 	FullName      string `json:"full_name"` | ||||
| 	Website       string `json:"website"` | ||||
| 	Description   string `json:"description"` | ||||
| 	Location      string `json:"location"` | ||||
| 	Language      string `json:"language"` | ||||
| 	Theme         string `json:"theme"` | ||||
| 	DiffViewStyle string `json:"diff_view_style"` | ||||
| 	// Privacy | ||||
| 	HideEmail    bool `json:"hide_email"` | ||||
| 	HideActivity bool `json:"hide_activity"` | ||||
| } | ||||
|  | ||||
| // UserSettingsOptions represents options to change user settings | ||||
| type UserSettingsOptions struct { | ||||
| 	FullName      *string `json:"full_name,omitempty"` | ||||
| 	Website       *string `json:"website,omitempty"` | ||||
| 	Description   *string `json:"description,omitempty"` | ||||
| 	Location      *string `json:"location,omitempty"` | ||||
| 	Language      *string `json:"language,omitempty"` | ||||
| 	Theme         *string `json:"theme,omitempty"` | ||||
| 	DiffViewStyle *string `json:"diff_view_style,omitempty"` | ||||
| 	// Privacy | ||||
| 	HideEmail    *bool `json:"hide_email,omitempty"` | ||||
| 	HideActivity *bool `json:"hide_activity,omitempty"` | ||||
| } | ||||
|  | ||||
| // GetUserSettings returns user settings | ||||
| func (c *Client) GetUserSettings() (*UserSettings, *Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	userConfig := new(UserSettings) | ||||
| 	resp, err := c.getParsedResponse("GET", "/user/settings", nil, nil, userConfig) | ||||
| 	return userConfig, resp, err | ||||
| } | ||||
|  | ||||
| // UpdateUserSettings returns user settings | ||||
| func (c *Client) UpdateUserSettings(opt UserSettingsOptions) (*UserSettings, *Response, error) { | ||||
| 	if err := c.checkServerVersionGreaterThanOrEqual(version1_15_0); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	userConfig := new(UserSettings) | ||||
| 	resp, err := c.getParsedResponse("PATCH", "/user/settings", jsonHeader, bytes.NewReader(body), userConfig) | ||||
| 	return userConfig, resp, err | ||||
| } | ||||
							
								
								
									
										1
									
								
								vendor/code.gitea.io/sdk/gitea/version.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/code.gitea.io/sdk/gitea/version.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -45,6 +45,7 @@ var ( | ||||
| 	version1_12_0, _ = version.NewVersion("1.12.0") | ||||
| 	version1_13_0, _ = version.NewVersion("1.13.0") | ||||
| 	version1_14_0, _ = version.NewVersion("1.14.0") | ||||
| 	version1_15_0, _ = version.NewVersion("1.15.0") | ||||
| ) | ||||
|  | ||||
| // checkServerVersionGreaterThanOrEqual is internally used to speed up things and ignore issues with prerelease | ||||
|   | ||||
							
								
								
									
										25
									
								
								vendor/github.com/hashicorp/go-version/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								vendor/github.com/hashicorp/go-version/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| # 1.3.0 (March 31, 2021) | ||||
|  | ||||
| Please note that CHANGELOG.md does not exist in the source code prior to this release. | ||||
|  | ||||
| FEATURES: | ||||
|  - Add `Core` function to return a version without prerelease or metadata ([#85](https://github.com/hashicorp/go-version/pull/85)) | ||||
|  | ||||
| # 1.2.1 (June 17, 2020) | ||||
|  | ||||
| BUG FIXES: | ||||
|  - Prevent `Version.Equal` method from panicking on `nil` encounter ([#73](https://github.com/hashicorp/go-version/pull/73)) | ||||
|  | ||||
| # 1.2.0 (April 23, 2019) | ||||
|  | ||||
| FEATURES: | ||||
|  - Add `GreaterThanOrEqual` and `LessThanOrEqual` helper methods ([#53](https://github.com/hashicorp/go-version/pull/53)) | ||||
|  | ||||
| # 1.1.0 (Jan 07, 2019) | ||||
|  | ||||
| FEATURES: | ||||
|  - Add `NewSemver` constructor ([#45](https://github.com/hashicorp/go-version/pull/45)) | ||||
|  | ||||
| # 1.0.0 (August 24, 2018) | ||||
|  | ||||
| Initial release. | ||||
							
								
								
									
										8
									
								
								vendor/github.com/hashicorp/go-version/version.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								vendor/github.com/hashicorp/go-version/version.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -278,6 +278,14 @@ func comparePrereleases(v string, other string) int { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| // Core returns a new version constructed from only the MAJOR.MINOR.PATCH | ||||
| // segments of the version, without prerelease or metadata. | ||||
| func (v *Version) Core() *Version { | ||||
| 	segments := v.Segments64() | ||||
| 	segmentsOnly := fmt.Sprintf("%d.%d.%d", segments[0], segments[1], segments[2]) | ||||
| 	return Must(NewVersion(segmentsOnly)) | ||||
| } | ||||
|  | ||||
| // Equal tests if two versions are equal. | ||||
| func (v *Version) Equal(o *Version) bool { | ||||
| 	if v == nil || o == nil { | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							| @@ -1,7 +1,7 @@ | ||||
| # code.gitea.io/gitea-vet v0.2.1 | ||||
| code.gitea.io/gitea-vet | ||||
| code.gitea.io/gitea-vet/checks | ||||
| # code.gitea.io/sdk/gitea v0.13.1-0.20210304201955-ff82113459b5 | ||||
| # code.gitea.io/sdk/gitea v0.15.0 | ||||
| code.gitea.io/sdk/gitea | ||||
| # gitea.com/noerw/unidiff-comments v0.0.0-20201219085024-64aec5658f2b | ||||
| gitea.com/noerw/unidiff-comments | ||||
| @@ -131,7 +131,7 @@ github.com/go-git/go-git/v5/utils/merkletrie/internal/frame | ||||
| github.com/go-git/go-git/v5/utils/merkletrie/noder | ||||
| # github.com/gorilla/css v1.0.0 | ||||
| github.com/gorilla/css/scanner | ||||
| # github.com/hashicorp/go-version v1.2.1 | ||||
| # github.com/hashicorp/go-version v1.3.0 | ||||
| github.com/hashicorp/go-version | ||||
| # github.com/imdario/mergo v0.3.11 | ||||
| github.com/imdario/mergo | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 6543
					6543