Refactor codes to remove structs and depend them on code.gitea.io/gitea/modules/structs (#171)
* refactor codes to remove structs and depend them on code.gitea.io/gitea/modules/structs * fix testing
This commit is contained in:
parent
13ec4d170b
commit
38803cbe75
42 changed files with 389 additions and 1656 deletions
1
Makefile
1
Makefile
|
@ -22,6 +22,7 @@ fmt:
|
|||
|
||||
.PHONY: vet
|
||||
vet:
|
||||
go get code.gitea.io/gitea/modules/structs
|
||||
go vet $(PACKAGES)
|
||||
|
||||
.PHONY: lint
|
||||
|
|
|
@ -8,10 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// AdminCreateOrg create an organization
|
||||
func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error) {
|
||||
func (c *Client) AdminCreateOrg(user string, opt structs.CreateOrgOption) (*Organization, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -8,10 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// AdminCreateRepo create a repo
|
||||
func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, error) {
|
||||
func (c *Client) AdminCreateRepo(user string, opt structs.CreateRepoOption) (*Repository, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -9,26 +9,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// CreateUserOption create user options
|
||||
type CreateUserOption struct {
|
||||
SourceID int64 `json:"source_id"`
|
||||
LoginName string `json:"login_name"`
|
||||
// required: true
|
||||
Username string `json:"username" binding:"Required;AlphaDashDot;MaxSize(40)"`
|
||||
FullName string `json:"full_name" binding:"MaxSize(100)"`
|
||||
// required: true
|
||||
// swagger:strfmt email
|
||||
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
||||
// required: true
|
||||
Password string `json:"password" binding:"Required;MaxSize(255)"`
|
||||
MustChangePassword *bool `json:"must_change_password"`
|
||||
SendNotify bool `json:"send_notify"`
|
||||
}
|
||||
|
||||
// AdminCreateUser create a user
|
||||
func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) {
|
||||
func (c *Client) AdminCreateUser(opt structs.CreateUserOption) (*User, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -37,29 +23,8 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) {
|
|||
return user, c.getParsedResponse("POST", "/admin/users", jsonHeader, bytes.NewReader(body), user)
|
||||
}
|
||||
|
||||
// EditUserOption edit user options
|
||||
type EditUserOption struct {
|
||||
SourceID int64 `json:"source_id"`
|
||||
LoginName string `json:"login_name"`
|
||||
FullName string `json:"full_name" binding:"MaxSize(100)"`
|
||||
// required: true
|
||||
// swagger:strfmt email
|
||||
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
||||
Password string `json:"password" binding:"MaxSize(255)"`
|
||||
MustChangePassword *bool `json:"must_change_password"`
|
||||
Website string `json:"website" binding:"MaxSize(50)"`
|
||||
Location string `json:"location" binding:"MaxSize(50)"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// AdminEditUser modify user informations
|
||||
func (c *Client) AdminEditUser(user string, opt EditUserOption) error {
|
||||
func (c *Client) AdminEditUser(user string, opt structs.EditUserOption) error {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -75,7 +40,7 @@ func (c *Client) AdminDeleteUser(user string) error {
|
|||
}
|
||||
|
||||
// AdminCreateUserPublicKey create one user with options
|
||||
func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) {
|
||||
func (c *Client) AdminCreateUserPublicKey(user string, opt structs.CreateKeyOption) (*PublicKey, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -10,21 +10,12 @@ import (
|
|||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Attachment a generic attachment
|
||||
// swagger:model
|
||||
type Attachment struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Size int64 `json:"size"`
|
||||
DownloadCount int64 `json:"download_count"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
UUID string `json:"uuid"`
|
||||
DownloadURL string `json:"browser_download_url"`
|
||||
}
|
||||
// Attachment is equal to structs.Attachment
|
||||
type Attachment = structs.Attachment
|
||||
|
||||
// ListReleaseAttachments list release's attachments
|
||||
func (c *Client) ListReleaseAttachments(user, repo string, release int64) ([]*Attachment, error) {
|
||||
|
@ -70,7 +61,7 @@ func (c *Client) CreateReleaseAttachment(user, repo string, release int64, file
|
|||
}
|
||||
|
||||
// EditReleaseAttachment updates the given attachment with the given options
|
||||
func (c *Client) EditReleaseAttachment(user, repo string, release int64, attachment int64, form EditAttachmentOptions) (*Attachment, error) {
|
||||
func (c *Client) EditReleaseAttachment(user, repo string, release int64, attachment int64, form structs.EditAttachmentOptions) (*Attachment, error) {
|
||||
body, err := json.Marshal(&form)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -84,9 +75,3 @@ func (c *Client) DeleteReleaseAttachment(user, repo string, release int64, id in
|
|||
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, id), nil, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
// EditAttachmentOptions options for editing attachments
|
||||
// swagger:model
|
||||
type EditAttachmentOptions struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
var jsonHeader = http.Header{"content-type": []string{"application/json"}}
|
||||
|
||||
// Version return the library version
|
||||
func Version() string {
|
||||
return "0.12.3"
|
|
@ -8,6 +8,8 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// ListForks list a repository's forks
|
||||
|
@ -19,14 +21,8 @@ func (c *Client) ListForks(user, repo string) ([]*Repository, error) {
|
|||
return forks, err
|
||||
}
|
||||
|
||||
// CreateForkOption options for creating a fork
|
||||
type CreateForkOption struct {
|
||||
// organization name, if forking into an organization
|
||||
Organization *string `json:"organization"`
|
||||
}
|
||||
|
||||
// CreateFork create a fork of a repository
|
||||
func (c *Client) CreateFork(user, repo string, form CreateForkOption) (*Repository, error) {
|
||||
func (c *Client) CreateFork(user, repo string, form structs.CreateForkOption) (*Repository, error) {
|
||||
body, err := json.Marshal(form)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright 2019 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
|
||||
|
||||
// GitBlobResponse represents a git blob
|
||||
type GitBlobResponse struct {
|
||||
Content string `json:"content"`
|
||||
Encoding string `json:"encoding"`
|
||||
URL string `json:"url"`
|
||||
SHA string `json:"sha"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
|
@ -8,17 +8,15 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// GitHook represents a Git repository hook
|
||||
type GitHook struct {
|
||||
Name string `json:"name"`
|
||||
IsActive bool `json:"is_active"`
|
||||
Content string `json:"content,omitempty"`
|
||||
}
|
||||
// GitHook is equal to structs.GitHook
|
||||
type GitHook = structs.GitHook
|
||||
|
||||
// GitHookList represents a list of Git hooks
|
||||
type GitHookList []*GitHook
|
||||
// GitHookList is equal to structs.GitHookList
|
||||
type GitHookList = structs.GitHookList
|
||||
|
||||
// ListRepoGitHooks list all the Git hooks of one repository
|
||||
func (c *Client) ListRepoGitHooks(user, repo string) (GitHookList, error) {
|
||||
|
@ -32,13 +30,8 @@ func (c *Client) GetRepoGitHook(user, repo, id string) (*GitHook, error) {
|
|||
return h, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), nil, nil, h)
|
||||
}
|
||||
|
||||
// EditGitHookOption options when modifying one Git hook
|
||||
type EditGitHookOption struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// EditRepoGitHook modify one Git hook of a repository
|
||||
func (c *Client) EditRepoGitHook(user, repo, id string, opt EditGitHookOption) error {
|
||||
func (c *Client) EditRepoGitHook(user, repo, id string, opt structs.EditGitHookOption) error {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
5
gitea/go.mod
Normal file
5
gitea/go.mod
Normal file
|
@ -0,0 +1,5 @@
|
|||
module code.gitea.io/sdk/gitea
|
||||
|
||||
go 1.12
|
||||
|
||||
require code.gitea.io/gitea v1.9.0-dev.0.20190511102134-34eee25bd42d
|
207
gitea/go.sum
Normal file
207
gitea/go.sum
Normal file
|
@ -0,0 +1,207 @@
|
|||
cloud.google.com/go v0.30.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
code.gitea.io/gitea v1.9.0-dev.0.20190511102134-34eee25bd42d h1:e7CG8dgMKc6QJBE+0ETDBV/CAq4HVSGVRpfntmA1MTA=
|
||||
code.gitea.io/gitea v1.9.0-dev.0.20190511102134-34eee25bd42d/go.mod h1:CRS1CnvXBT65wMm8ooow8D4Qe0tspETh7qlBwj+9/Bk=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/PuerkitoBio/goquery v0.0.0-20170324135448-ed7d758e9a34/go.mod h1:T9ezsOHcCrDCgA8aF1Cqr3sSYbO/xgdy8/R/XiIMAhA=
|
||||
github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w=
|
||||
github.com/Unknwon/cae v0.0.0-20160715032808-c6aac99ea2ca/go.mod h1:IRSre9/SEhVuy972TVuJLyaPTS73+8Owhe0Y0l9NXHc=
|
||||
github.com/Unknwon/com v0.0.0-20170819223952-7677a1d7c113/go.mod h1:KYCjqMOeHpNuTOiFQU6WEcTG7poCJrUs0YgyHNtn1no=
|
||||
github.com/Unknwon/i18n v0.0.0-20171114194641-b64d33658966/go.mod h1:SFtfq0zFPsENI7DpE87QM2hcYu5QQ0fRdCgP+P1Hrqo=
|
||||
github.com/Unknwon/paginater v0.0.0-20151104151617-7748a72e0141/go.mod h1:fw0McLecf/G5NFwddCRmDckU6yovtk1YsgWIoepMbYo=
|
||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
||||
github.com/andybalholm/cascadia v0.0.0-20161224141413-349dd0209470/go.mod h1:3I+3V7B6gTBYfdpYgIG2ymALS9H+5VDKUl3lHH7ToM4=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/blevesearch/bleve v0.0.0-20190214220507-05d86ea8f6e3/go.mod h1:Y2lmIkzV6mcNfAnAdOd+ZxHkHchhBfU/xroGIp61wfw=
|
||||
github.com/blevesearch/blevex v0.0.0-20180227211930-4b158bb555a3/go.mod h1:WH+MU2F4T0VmSdaPX+Wu5GYoZBrYWdOZWSjzvYcDmqQ=
|
||||
github.com/blevesearch/go-porterstemmer v0.0.0-20141230013033-23a2c8e5cf1f/go.mod h1:haWQqFT3RdOGz7PJuM3or/pWNJS1pKkoZJWCkWu0DVA=
|
||||
github.com/blevesearch/segment v0.0.0-20160105220820-db70c57796cc/go.mod h1:IInt5XRvpiGE09KOk9mmCMLjHhydIhNPKPPFLFBB7L8=
|
||||
github.com/boombuler/barcode v0.0.0-20161226211916-fe0f26ff6d26/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20160117192205-fb1f79c6b65a/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
||||
github.com/chaseadamsio/goorgeous v0.0.0-20170901132237-098da33fde5f/go.mod h1:6QaC0vFoKWYDth94dHFNgRT2YkT5FHdQp/Yx15aAAi0=
|
||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||
github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
|
||||
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
|
||||
github.com/couchbase/vellum v0.0.0-20190111184608-e91b68ff3efe/go.mod h1:prYTC8EgTu3gwbqJihkud9zRXISvyulAplQ6exdCo1g=
|
||||
github.com/couchbaselabs/go-couchbase v0.0.0-20190117181324-d904413d884d/go.mod h1:mby/05p8HE5yHEAKiIH/555NoblMs7PtW6NrYshDruc=
|
||||
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d/go.mod h1:URriBxXwVq5ijiJ12C7iIZqlA69nTlI+LgI6/pwftG8=
|
||||
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM=
|
||||
github.com/cznic/strutil v0.0.0-20181122101858-275e90344537/go.mod h1:AHHPPPXTw0h6pVabbcbyGRK1DckRn7r/STdZEeIDzZc=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20181014144952-4e0d7dc8888f/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc=
|
||||
github.com/dgrijalva/jwt-go v0.0.0-20161101193935-9ed569b5d1ac/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/elazarl/go-bindata-assetfs v0.0.0-20151224045452-57eb5e1fc594/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||
github.com/emirpasic/gods v1.9.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
github.com/etcd-io/bbolt v1.3.2/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
|
||||
github.com/ethantkoenig/rupture v0.0.0-20180203182544-0a76f03a811a/go.mod h1:MkKY/CB98aVE4VxO63X5vTQKUgcn+3XP15LMASe3lYs=
|
||||
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a/go.mod h1:7Ga40egUymuWXxAe151lTNnCv97MddSOVsjpPPkityA=
|
||||
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
|
||||
github.com/facebookgo/freeport v0.0.0-20150612182905-d4adf43b75b9/go.mod h1:uPmAp6Sws4L7+Q/OokbWDAK1ibXYhB3PXFP1kol5hPg=
|
||||
github.com/facebookgo/grace v0.0.0-20160926231715-5729e484473f/go.mod h1:KigFdumBXUPSwzLDbeuzyt0elrL7+CP7TKuhrhT4bcU=
|
||||
github.com/facebookgo/httpdown v0.0.0-20160323221027-a3b1354551a2/go.mod h1:TUV/fX3XrTtBQb5+ttSUJzcFgLNpILONFTKmBuk5RSw=
|
||||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg=
|
||||
github.com/facebookgo/stats v0.0.0-20151006221625-1b76add642e4/go.mod h1:vsJz7uE339KUCpBXx3JAJzSRH7Uk4iGGyJzR529qDIA=
|
||||
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
|
||||
github.com/glycerine/goconvey v0.0.0-20190315024820-982ee783a72e/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
|
||||
github.com/go-macaron/bindata v0.0.0-20161222093048-85786f57eee3/go.mod h1:NkmXhFuAlCOqgV5EWhU1DKLrgztCEIVXGmr2DZv/+sk=
|
||||
github.com/go-macaron/binding v0.0.0-20160711225916-9440f336b443/go.mod h1:u+H6rwW+HQwUL+w5uaEJSpIlVZDye1o9MB4Su0JfRfM=
|
||||
github.com/go-macaron/cache v0.0.0-20151013081102-561735312776/go.mod h1:hHAsZm/oBZVcY+S7qdQL6Vbg5VrXF6RuKGuqsszt3Ok=
|
||||
github.com/go-macaron/captcha v0.0.0-20151123225153-8aa5919789ab/go.mod h1:j9TJ+0nwUOWBvNnm0bheHIPFf3cC62EQo7n7O6PbjZA=
|
||||
github.com/go-macaron/csrf v0.0.0-20180426211211-503617c6b372/go.mod h1:oZGMxI7MBnicI0jJqJvH4qQzyrWKhtiKxLSJKHC+ydc=
|
||||
github.com/go-macaron/i18n v0.0.0-20160612092837-ef57533c3b0f/go.mod h1:MePM/dStkAh+PNzAdNSNl4SGDM2EZvZGken+KpJhM7s=
|
||||
github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191/go.mod h1:VFI2o2q9kYsC4o7VP1HrEVosiZZTd+MVT3YZx4gqvJw=
|
||||
github.com/go-macaron/session v0.0.0-20190131233854-0a0a789bf193/go.mod h1:ScEJm9Gk+ez5JJTml5WlBIqavAfuE5nF8e4Gvyz/X+A=
|
||||
github.com/go-macaron/toolbox v0.0.0-20180818072302-a77f45a7ce90/go.mod h1:Ut/NmkIMGVYlEdJBzEZgWVWG5ZpYS9BLmUgXfAgi+qM=
|
||||
github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-xorm/builder v0.3.2/go.mod h1:v8mE3MFBgtL+RGFNfUnAMUqqfk/Y4W5KuwCFQIEpQLk=
|
||||
github.com/go-xorm/builder v0.3.3/go.mod h1:v8mE3MFBgtL+RGFNfUnAMUqqfk/Y4W5KuwCFQIEpQLk=
|
||||
github.com/go-xorm/core v0.6.0/go.mod h1:d8FJ9Br8OGyQl12MCclmYBuBqqxsyeedpXciV5Myih8=
|
||||
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
|
||||
github.com/go-xorm/xorm v0.0.0-20190116032649-a6300f2a45e0/go.mod h1:EHS1htMQFptzMaIHKyzqpHGw6C9Rtug75nsq6DA9unI=
|
||||
github.com/gogits/chardet v0.0.0-20150115103509-2404f7772561/go.mod h1:YgYOrVn3Nj9Tq0EvjmFbphRytDj7JNRoWSStJZWDJTQ=
|
||||
github.com/gogits/cron v0.0.0-20160810035002-7f3990acf183/go.mod h1:pX+V62FFmklia2fhP3P4YSY6iJdPO5jIDKFQ5fEd5QE=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
||||
github.com/google/go-github/v24 v24.0.1/go.mod h1:CRqaW1Uns1TCkP0wqTpxYyRxRjxwvKU/XSS44u6X74M=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/pat v0.0.0-20180118222023-199c85a7f6d1/go.mod h1:YeAe0gNeiNT5hoiZRI4yiOky6jVdNvfO2N6Kav/HmxY=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/gorilla/sessions v1.1.1/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/issue9/assert v1.3.2/go.mod h1:9Ger+iz8X7r1zMYYwEhh++2wMGWcNN2oVI+zIQXxcio=
|
||||
github.com/issue9/identicon v0.0.0-20160320065130-d36b54562f4c/go.mod h1:5mTb/PQNkqmq2x3IxlQZE0aSnTksJg7fg/oWmJ5SKXQ=
|
||||
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ=
|
||||
github.com/jackc/pgx v3.2.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I=
|
||||
github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4=
|
||||
github.com/jaytaylor/html2text v0.0.0-20160923191438-8fb95d837f7d/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/kballard/go-shellquote v0.0.0-20170619183022-cd60e84ee657/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/keybase/go-crypto v0.0.0-20170605145657-00ac4db533f6/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v0.0.0-20161025140425-8df558b6cb6f/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/cpuid v0.0.0-20160302075316-09cded8978dc/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lafriks/xormstore v1.0.0/go.mod h1:dD8vHNRfEp3Uy+JvX9cMi2SXcRKJ0x4pYKsZuy843Ic=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96/go.mod h1:mmIfjCSQlGYXmJ95jFN84AkQFnVABtKuJL8IrzwvUKQ=
|
||||
github.com/lunny/levelqueue v0.0.0-20190217115915-02b525a4418e/go.mod h1:rQZVENnBOiVakCs97XvclbwJRTAv77CRFWcYVNDkVf8=
|
||||
github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de/go.mod h1:3q8WtuPQsoRbatJuy3nvq/hRSvuBJrHHr+ybPPiNvHQ=
|
||||
github.com/lunny/nodb v0.0.0-20160621015157-fc1ef06ad4af/go.mod h1:Cqz6pqow14VObJ7peltM+2n3PWOz7yTrfUuGbVFkzN0=
|
||||
github.com/markbates/going v1.0.0/go.mod h1:I6mnB4BPnEeqo85ynXIx1ZFLLbtiLHNXVgWeFO9OGOA=
|
||||
github.com/markbates/goth v1.49.0/go.mod h1:zZmAw0Es0Dpm7TT/4AdN14QrkiWLMrrU9Xei1o+/mdA=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-oci8 v0.0.0-20190320171441-14ba190cf52d/go.mod h1:/M9VLO+lUPmxvoOK2PfWRZ8mTtB4q1Hy9lEGijv9Nr8=
|
||||
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75/go.mod h1:76rfSfYPWj01Z85hUf/ituArm797mNKcvINh1OlsZKo=
|
||||
github.com/microcosm-cc/bluemonday v0.0.0-20161012083705-f77f16ffc87a/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mrjones/oauth v0.0.0-20180629183705-f4e24b6d100c/go.mod h1:skjdDftzkFALcuGzYSklqYd8gvat6F1gZJ4YPVbkZpM=
|
||||
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg=
|
||||
github.com/msteinert/pam v0.0.0-20151204160544-02ccfbfaf0cc/go.mod h1:np1wUFZ6tyoke22qDJZY40URn9Ae51gX7ljIWXN5TJs=
|
||||
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
|
||||
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pquerna/otp v0.0.0-20160912161815-54653902c20e/go.mod h1:Zad1CMQfSQZI5KLpahDiSUX4tMMREnXw98IvL1nhgMk=
|
||||
github.com/prometheus/client_golang v0.9.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/russross/blackfriday v0.0.0-20180428102519-11635eb403ff/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20160918041101-1dba4b3954bc/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d/go.mod h1:vq0tzqLRu6TS7Id0wMo2N5QzJoKedVeovOpHjnykSzY=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff/go.mod h1:KSQcGKpxUMHk3nbYzs/tIBAM2iDooCn0BmttHOJEbLs=
|
||||
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
|
||||
github.com/steveyen/gtreap v0.0.0-20150807155958-0abe01ef9be2/go.mod h1:mjqs7N0Q6m5HpR7QfXVBZXZWSqTjQLeTujjA/xUp2uw=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/syndtr/goleveldb v0.0.0-20190203031304-2f17a3356c66/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||
github.com/tecbot/gorocksdb v0.0.0-20181010114359-8752a9433481/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
|
||||
github.com/tinylib/msgp v0.0.0-20180516164116-c8cf64dff200/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||
github.com/tstranex/u2f v1.0.0/go.mod h1:eahSLaqAS0zsIEv80+vXT7WanXs7MQQDg3j3wGBSayo=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/willf/bitset v0.0.0-20180426185212-8ce1146b8621/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/xanzy/ssh-agent v0.2.0/go.mod h1:0NyE30eGUDliuLEHJgYte/zncp2zdTStcOnWhgSqHD8=
|
||||
github.com/yohcop/openid-go v0.0.0-20160914080427-2c050d2dae53/go.mod h1:f6elajwZV+xceiaqgRL090YzLEDGSbqr3poGL3ZgXYo=
|
||||
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/oauth2 v0.0.0-20180620175406-ef147856a6dd/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20181101160152-c453e0c75759/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||
gopkg.in/asn1-ber.v1 v1.0.0-20150924051756-4e86f4367175/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw=
|
||||
gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e/go.mod h1:xsQCaysVCudhrYTfzYWe577fCe7Ceci+6qjO2Rdc0Z4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.2.0/go.mod h1:s2mQFI9McjArkyCwyEwU//+luQENTnD/Lfb/7Sj3/kQ=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
||||
gopkg.in/ini.v1 v1.31.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ldap.v3 v3.0.2/go.mod h1:oxD7NyBuxchC+SgJDE1Q5Od05eGt29SDQVBmV+HYbzw=
|
||||
gopkg.in/macaron.v1 v1.3.2/go.mod h1:PrsiawTWAGZs6wFbT5hlr7SQ2Ns9h7cUVtcUu4lQOVo=
|
||||
gopkg.in/redis.v2 v2.3.2/go.mod h1:4wl9PJ/CqzeHk3LVq1hNLHH8krm3+AXEgut4jVc++LU=
|
||||
gopkg.in/src-d/go-billy.v4 v4.2.1/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
|
||||
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
|
||||
gopkg.in/src-d/go-git-fixtures.v3 v3.1.1/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
|
||||
gopkg.in/src-d/go-git.v4 v4.10.0/go.mod h1:Vtut8izDyrM8BUVQnzJ+YvmNcem2J89EmfZYCkLokZk=
|
||||
gopkg.in/stretchr/testify.v1 v1.2.2/go.mod h1:QI5V/q6UbPmuhtm10CaFZxED9NreB8PnFYN9JcR6TxU=
|
||||
gopkg.in/testfixtures.v2 v2.5.0/go.mod h1:vyAq+MYCgNpR29qitQdLZhdbLFf4mR/2MFJRFoQZZ2M=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
mvdan.cc/xurls/v2 v2.0.0/go.mod h1:2/webFPYOXN9jp/lzuj0zuAVlF+9g4KPFJANH1oJhRU=
|
||||
strk.kbt.io/projects/go/libravatar v0.0.0-20160628055650-5eed7bff870a/go.mod h1:FJGmPh3vz9jSos1L/F91iAgnC/aejc0wIIrF2ZwJxdY=
|
467
gitea/hook.go
467
gitea/hook.go
|
@ -8,33 +8,16 @@ package gitea
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrInvalidReceiveHook FIXME
|
||||
ErrInvalidReceiveHook = errors.New("Invalid JSON payload received over webhook")
|
||||
)
|
||||
// Hook is equal to structs.Hook
|
||||
type Hook = structs.Hook
|
||||
|
||||
// Hook a hook is a web hook when one repository changed
|
||||
type Hook struct {
|
||||
ID int64 `json:"id"`
|
||||
Type string `json:"type"`
|
||||
URL string `json:"-"`
|
||||
Config map[string]string `json:"config"`
|
||||
Events []string `json:"events"`
|
||||
Active bool `json:"active"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// HookList represents a list of API hook.
|
||||
type HookList []*Hook
|
||||
// HookList is equal to structs.HookList
|
||||
type HookList = structs.HookList
|
||||
|
||||
// ListOrgHooks list all the hooks of one organization
|
||||
func (c *Client) ListOrgHooks(org string) (HookList, error) {
|
||||
|
@ -60,20 +43,8 @@ func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, error) {
|
|||
return h, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil, h)
|
||||
}
|
||||
|
||||
// CreateHookOption options when create a hook
|
||||
type CreateHookOption struct {
|
||||
// required: true
|
||||
// enum: gitea,gogs,slack,discord
|
||||
Type string `json:"type" binding:"Required"`
|
||||
// required: true
|
||||
Config map[string]string `json:"config" binding:"Required"`
|
||||
Events []string `json:"events"`
|
||||
// default: false
|
||||
Active bool `json:"active"`
|
||||
}
|
||||
|
||||
// CreateOrgHook create one hook for an organization, with options
|
||||
func (c *Client) CreateOrgHook(org string, opt CreateHookOption) (*Hook, error) {
|
||||
func (c *Client) CreateOrgHook(org string, opt structs.CreateHookOption) (*Hook, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -83,7 +54,7 @@ func (c *Client) CreateOrgHook(org string, opt CreateHookOption) (*Hook, error)
|
|||
}
|
||||
|
||||
// CreateRepoHook create one hook for a repository, with options
|
||||
func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook, error) {
|
||||
func (c *Client) CreateRepoHook(user, repo string, opt structs.CreateHookOption) (*Hook, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -92,15 +63,8 @@ func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook,
|
|||
return h, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), jsonHeader, bytes.NewReader(body), h)
|
||||
}
|
||||
|
||||
// EditHookOption options when modify one hook
|
||||
type EditHookOption struct {
|
||||
Config map[string]string `json:"config"`
|
||||
Events []string `json:"events"`
|
||||
Active *bool `json:"active"`
|
||||
}
|
||||
|
||||
// EditOrgHook modify one hook of an organization, with hook id and options
|
||||
func (c *Client) EditOrgHook(org string, id int64, opt EditHookOption) error {
|
||||
func (c *Client) EditOrgHook(org string, id int64, opt structs.EditHookOption) error {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -110,7 +74,7 @@ func (c *Client) EditOrgHook(org string, id int64, opt EditHookOption) error {
|
|||
}
|
||||
|
||||
// EditRepoHook modify one hook of a repository, with hook id and options
|
||||
func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) error {
|
||||
func (c *Client) EditRepoHook(user, repo string, id int64, opt structs.EditHookOption) error {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -130,414 +94,3 @@ func (c *Client) DeleteRepoHook(user, repo string, id int64) error {
|
|||
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
// Payloader payload is some part of one hook
|
||||
type Payloader interface {
|
||||
SetSecret(string)
|
||||
JSONPayload() ([]byte, error)
|
||||
}
|
||||
|
||||
// PayloadUser represents the author or committer of a commit
|
||||
type PayloadUser struct {
|
||||
// Full name of the commit author
|
||||
Name string `json:"name"`
|
||||
// swagger:strfmt email
|
||||
Email string `json:"email"`
|
||||
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
|
||||
ID string `json:"id"`
|
||||
Message string `json:"message"`
|
||||
URL string `json:"url"`
|
||||
Author *PayloadUser `json:"author"`
|
||||
Committer *PayloadUser `json:"committer"`
|
||||
Verification *PayloadCommitVerification `json:"verification"`
|
||||
// swagger:strfmt date-time
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Added []string `json:"added"`
|
||||
Removed []string `json:"removed"`
|
||||
Modified []string `json:"modified"`
|
||||
}
|
||||
|
||||
// PayloadCommitVerification represents the GPG verification of a commit
|
||||
type PayloadCommitVerification struct {
|
||||
Verified bool `json:"verified"`
|
||||
Reason string `json:"reason"`
|
||||
Signature string `json:"signature"`
|
||||
Payload string `json:"payload"`
|
||||
}
|
||||
|
||||
var (
|
||||
_ Payloader = &CreatePayload{}
|
||||
_ Payloader = &DeletePayload{}
|
||||
_ Payloader = &ForkPayload{}
|
||||
_ Payloader = &PushPayload{}
|
||||
_ Payloader = &IssuePayload{}
|
||||
_ Payloader = &IssueCommentPayload{}
|
||||
_ Payloader = &PullRequestPayload{}
|
||||
_ Payloader = &RepositoryPayload{}
|
||||
_ Payloader = &ReleasePayload{}
|
||||
)
|
||||
|
||||
// _________ __
|
||||
// \_ ___ \_______ ____ _____ _/ |_ ____
|
||||
// / \ \/\_ __ \_/ __ \\__ \\ __\/ __ \
|
||||
// \ \____| | \/\ ___/ / __ \| | \ ___/
|
||||
// \______ /|__| \___ >____ /__| \___ >
|
||||
// \/ \/ \/ \/
|
||||
|
||||
// CreatePayload FIXME
|
||||
type CreatePayload struct {
|
||||
Secret string `json:"secret"`
|
||||
Sha string `json:"sha"`
|
||||
Ref string `json:"ref"`
|
||||
RefType string `json:"ref_type"`
|
||||
Repo *Repository `json:"repository"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// SetSecret modifies the secret of the CreatePayload
|
||||
func (p *CreatePayload) SetSecret(secret string) {
|
||||
p.Secret = secret
|
||||
}
|
||||
|
||||
// JSONPayload return payload information
|
||||
func (p *CreatePayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// ParseCreateHook parses create event hook content.
|
||||
func ParseCreateHook(raw []byte) (*CreatePayload, error) {
|
||||
hook := new(CreatePayload)
|
||||
if err := json.Unmarshal(raw, hook); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// it is possible the JSON was parsed, however,
|
||||
// was not from Gogs (maybe was from Bitbucket)
|
||||
// So we'll check to be sure certain key fields
|
||||
// were populated
|
||||
switch {
|
||||
case hook.Repo == nil:
|
||||
return nil, ErrInvalidReceiveHook
|
||||
case len(hook.Ref) == 0:
|
||||
return nil, ErrInvalidReceiveHook
|
||||
}
|
||||
return hook, nil
|
||||
}
|
||||
|
||||
// ________ .__ __
|
||||
// \______ \ ____ | | _____/ |_ ____
|
||||
// | | \_/ __ \| | _/ __ \ __\/ __ \
|
||||
// | ` \ ___/| |_\ ___/| | \ ___/
|
||||
// /_______ /\___ >____/\___ >__| \___ >
|
||||
// \/ \/ \/ \/
|
||||
|
||||
// PusherType define the type to push
|
||||
type PusherType string
|
||||
|
||||
// describe all the PusherTypes
|
||||
const (
|
||||
PusherTypeUser PusherType = "user"
|
||||
)
|
||||
|
||||
// DeletePayload represents delete payload
|
||||
type DeletePayload struct {
|
||||
Secret string `json:"secret"`
|
||||
Ref string `json:"ref"`
|
||||
RefType string `json:"ref_type"`
|
||||
PusherType PusherType `json:"pusher_type"`
|
||||
Repo *Repository `json:"repository"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// SetSecret modifies the secret of the DeletePayload
|
||||
func (p *DeletePayload) SetSecret(secret string) {
|
||||
p.Secret = secret
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *DeletePayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// ___________ __
|
||||
// \_ _____/__________| | __
|
||||
// | __)/ _ \_ __ \ |/ /
|
||||
// | \( <_> ) | \/ <
|
||||
// \___ / \____/|__| |__|_ \
|
||||
// \/ \/
|
||||
|
||||
// ForkPayload represents fork payload
|
||||
type ForkPayload struct {
|
||||
Secret string `json:"secret"`
|
||||
Forkee *Repository `json:"forkee"`
|
||||
Repo *Repository `json:"repository"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// SetSecret modifies the secret of the ForkPayload
|
||||
func (p *ForkPayload) SetSecret(secret string) {
|
||||
p.Secret = secret
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *ForkPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// HookIssueCommentAction defines hook issue comment action
|
||||
type HookIssueCommentAction string
|
||||
|
||||
// all issue comment actions
|
||||
const (
|
||||
HookIssueCommentCreated HookIssueCommentAction = "created"
|
||||
HookIssueCommentEdited HookIssueCommentAction = "edited"
|
||||
HookIssueCommentDeleted HookIssueCommentAction = "deleted"
|
||||
)
|
||||
|
||||
// IssueCommentPayload represents a payload information of issue comment event.
|
||||
type IssueCommentPayload struct {
|
||||
Secret string `json:"secret"`
|
||||
Action HookIssueCommentAction `json:"action"`
|
||||
Issue *Issue `json:"issue"`
|
||||
Comment *Comment `json:"comment"`
|
||||
Changes *ChangesPayload `json:"changes,omitempty"`
|
||||
Repository *Repository `json:"repository"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// SetSecret modifies the secret of the IssueCommentPayload
|
||||
func (p *IssueCommentPayload) SetSecret(secret string) {
|
||||
p.Secret = secret
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *IssueCommentPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// __________ .__
|
||||
// \______ \ ____ | | ____ _____ ______ ____
|
||||
// | _// __ \| | _/ __ \\__ \ / ___// __ \
|
||||
// | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/
|
||||
// |____|_ /\___ >____/\___ >____ /____ >\___ >
|
||||
// \/ \/ \/ \/ \/ \/
|
||||
|
||||
// HookReleaseAction defines hook release action type
|
||||
type HookReleaseAction string
|
||||
|
||||
// all release actions
|
||||
const (
|
||||
HookReleasePublished HookReleaseAction = "published"
|
||||
HookReleaseUpdated HookReleaseAction = "updated"
|
||||
HookReleaseDeleted HookReleaseAction = "deleted"
|
||||
)
|
||||
|
||||
// ReleasePayload represents a payload information of release event.
|
||||
type ReleasePayload struct {
|
||||
Secret string `json:"secret"`
|
||||
Action HookReleaseAction `json:"action"`
|
||||
Release *Release `json:"release"`
|
||||
Repository *Repository `json:"repository"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// SetSecret modifies the secret of the ReleasePayload
|
||||
func (p *ReleasePayload) SetSecret(secret string) {
|
||||
p.Secret = secret
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *ReleasePayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// __________ .__
|
||||
// \______ \__ __ _____| |__
|
||||
// | ___/ | \/ ___/ | \
|
||||
// | | | | /\___ \| Y \
|
||||
// |____| |____//____ >___| /
|
||||
// \/ \/
|
||||
|
||||
// PushPayload represents a payload information of push event.
|
||||
type PushPayload struct {
|
||||
Secret string `json:"secret"`
|
||||
Ref string `json:"ref"`
|
||||
Before string `json:"before"`
|
||||
After string `json:"after"`
|
||||
CompareURL string `json:"compare_url"`
|
||||
Commits []*PayloadCommit `json:"commits"`
|
||||
HeadCommit *PayloadCommit `json:"head_commit"`
|
||||
Repo *Repository `json:"repository"`
|
||||
Pusher *User `json:"pusher"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// SetSecret modifies the secret of the PushPayload
|
||||
func (p *PushPayload) SetSecret(secret string) {
|
||||
p.Secret = secret
|
||||
}
|
||||
|
||||
// JSONPayload FIXME
|
||||
func (p *PushPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// ParsePushHook parses push event hook content.
|
||||
func ParsePushHook(raw []byte) (*PushPayload, error) {
|
||||
hook := new(PushPayload)
|
||||
if err := json.Unmarshal(raw, hook); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch {
|
||||
case hook.Repo == nil:
|
||||
return nil, ErrInvalidReceiveHook
|
||||
case len(hook.Ref) == 0:
|
||||
return nil, ErrInvalidReceiveHook
|
||||
}
|
||||
return hook, nil
|
||||
}
|
||||
|
||||
// Branch returns branch name from a payload
|
||||
func (p *PushPayload) Branch() string {
|
||||
return strings.Replace(p.Ref, "refs/heads/", "", -1)
|
||||
}
|
||||
|
||||
// .___
|
||||
// | | ______ ________ __ ____
|
||||
// | |/ ___// ___/ | \_/ __ \
|
||||
// | |\___ \ \___ \| | /\ ___/
|
||||
// |___/____ >____ >____/ \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
// HookIssueAction FIXME
|
||||
type HookIssueAction string
|
||||
|
||||
const (
|
||||
// HookIssueOpened opened
|
||||
HookIssueOpened HookIssueAction = "opened"
|
||||
// HookIssueClosed closed
|
||||
HookIssueClosed HookIssueAction = "closed"
|
||||
// HookIssueReOpened reopened
|
||||
HookIssueReOpened HookIssueAction = "reopened"
|
||||
// HookIssueEdited edited
|
||||
HookIssueEdited HookIssueAction = "edited"
|
||||
// HookIssueAssigned assigned
|
||||
HookIssueAssigned HookIssueAction = "assigned"
|
||||
// HookIssueUnassigned unassigned
|
||||
HookIssueUnassigned HookIssueAction = "unassigned"
|
||||
// HookIssueLabelUpdated label_updated
|
||||
HookIssueLabelUpdated HookIssueAction = "label_updated"
|
||||
// HookIssueLabelCleared label_cleared
|
||||
HookIssueLabelCleared HookIssueAction = "label_cleared"
|
||||
// HookIssueSynchronized synchronized
|
||||
HookIssueSynchronized HookIssueAction = "synchronized"
|
||||
// HookIssueMilestoned is an issue action for when a milestone is set on an issue.
|
||||
HookIssueMilestoned HookIssueAction = "milestoned"
|
||||
// HookIssueDemilestoned is an issue action for when a milestone is cleared on an issue.
|
||||
HookIssueDemilestoned HookIssueAction = "demilestoned"
|
||||
)
|
||||
|
||||
// IssuePayload represents the payload information that is sent along with an issue event.
|
||||
type IssuePayload struct {
|
||||
Secret string `json:"secret"`
|
||||
Action HookIssueAction `json:"action"`
|
||||
Index int64 `json:"number"`
|
||||
Changes *ChangesPayload `json:"changes,omitempty"`
|
||||
Issue *Issue `json:"issue"`
|
||||
Repository *Repository `json:"repository"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// SetSecret modifies the secret of the IssuePayload.
|
||||
func (p *IssuePayload) SetSecret(secret string) {
|
||||
p.Secret = secret
|
||||
}
|
||||
|
||||
// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces.
|
||||
func (p *IssuePayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// ChangesFromPayload FIXME
|
||||
type ChangesFromPayload struct {
|
||||
From string `json:"from"`
|
||||
}
|
||||
|
||||
// ChangesPayload FIXME
|
||||
type ChangesPayload struct {
|
||||
Title *ChangesFromPayload `json:"title,omitempty"`
|
||||
Body *ChangesFromPayload `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// __________ .__ .__ __________ __
|
||||
// \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_
|
||||
// | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
|
||||
// | | | | / |_| |__ | | \ ___< <_| | | /\ ___/ \___ \ | |
|
||||
// |____| |____/|____/____/ |____|_ /\___ >__ |____/ \___ >____ > |__|
|
||||
// \/ \/ |__| \/ \/
|
||||
|
||||
// PullRequestPayload represents a payload information of pull request event.
|
||||
type PullRequestPayload struct {
|
||||
Secret string `json:"secret"`
|
||||
Action HookIssueAction `json:"action"`
|
||||
Index int64 `json:"number"`
|
||||
Changes *ChangesPayload `json:"changes,omitempty"`
|
||||
PullRequest *PullRequest `json:"pull_request"`
|
||||
Repository *Repository `json:"repository"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// SetSecret modifies the secret of the PullRequestPayload.
|
||||
func (p *PullRequestPayload) SetSecret(secret string) {
|
||||
p.Secret = secret
|
||||
}
|
||||
|
||||
// JSONPayload FIXME
|
||||
func (p *PullRequestPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
//__________ .__ __
|
||||
//\______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
|
||||
// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
|
||||
// | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
|
||||
// |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
|
||||
// \/ \/|__| \/ \/
|
||||
|
||||
// HookRepoAction an action that happens to a repo
|
||||
type HookRepoAction string
|
||||
|
||||
const (
|
||||
// HookRepoCreated created
|
||||
HookRepoCreated HookRepoAction = "created"
|
||||
// HookRepoDeleted deleted
|
||||
HookRepoDeleted HookRepoAction = "deleted"
|
||||
)
|
||||
|
||||
// RepositoryPayload payload for repository webhooks
|
||||
type RepositoryPayload struct {
|
||||
Secret string `json:"secret"`
|
||||
Action HookRepoAction `json:"action"`
|
||||
Repository *Repository `json:"repository"`
|
||||
Organization *User `json:"organization"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// SetSecret modifies the secret of the RepositoryPayload
|
||||
func (p *RepositoryPayload) SetSecret(secret string) {
|
||||
p.Secret = secret
|
||||
}
|
||||
|
||||
// JSONPayload JSON representation of the payload
|
||||
func (p *RepositoryPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
|
118
gitea/issue.go
118
gitea/issue.go
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2019 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.
|
||||
|
||||
|
@ -8,76 +9,30 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// StateType issue state type
|
||||
type StateType string
|
||||
// PullRequestMeta is equal to structs.PullRequestMeta
|
||||
type PullRequestMeta = structs.PullRequestMeta
|
||||
|
||||
const (
|
||||
// StateOpen pr is opend
|
||||
StateOpen StateType = "open"
|
||||
// StateClosed pr is closed
|
||||
StateClosed StateType = "closed"
|
||||
)
|
||||
|
||||
// PullRequestMeta PR info if an issue is a PR
|
||||
type PullRequestMeta struct {
|
||||
HasMerged bool `json:"merged"`
|
||||
Merged *time.Time `json:"merged_at"`
|
||||
}
|
||||
|
||||
// Issue represents an issue in a repository
|
||||
// swagger:model
|
||||
type Issue struct {
|
||||
ID int64 `json:"id"`
|
||||
URL string `json:"url"`
|
||||
Index int64 `json:"number"`
|
||||
Poster *User `json:"user"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Labels []*Label `json:"labels"`
|
||||
Milestone *Milestone `json:"milestone"`
|
||||
Assignee *User `json:"assignee"`
|
||||
Assignees []*User `json:"assignees"`
|
||||
// Whether the issue is open or closed
|
||||
//
|
||||
// type: string
|
||||
// enum: open,closed
|
||||
State StateType `json:"state"`
|
||||
Comments int `json:"comments"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
Closed *time.Time `json:"closed_at"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
|
||||
PullRequest *PullRequestMeta `json:"pull_request"`
|
||||
}
|
||||
|
||||
// ListIssueOption list issue options
|
||||
type ListIssueOption struct {
|
||||
Page int
|
||||
State string
|
||||
}
|
||||
// Issue is equal to structs.Issue
|
||||
type Issue = structs.Issue
|
||||
|
||||
// ListIssues returns all issues assigned the authenticated user
|
||||
func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, error) {
|
||||
func (c *Client) ListIssues(opt structs.ListIssueOption) ([]*Issue, error) {
|
||||
issues := make([]*Issue, 0, 10)
|
||||
return issues, c.getParsedResponse("GET", fmt.Sprintf("/issues?page=%d", opt.Page), nil, nil, &issues)
|
||||
}
|
||||
|
||||
// ListUserIssues returns all issues assigned to the authenticated user
|
||||
func (c *Client) ListUserIssues(opt ListIssueOption) ([]*Issue, error) {
|
||||
func (c *Client) ListUserIssues(opt structs.ListIssueOption) ([]*Issue, error) {
|
||||
issues := make([]*Issue, 0, 10)
|
||||
return issues, c.getParsedResponse("GET", fmt.Sprintf("/user/issues?page=%d", opt.Page), nil, nil, &issues)
|
||||
}
|
||||
|
||||
// ListRepoIssues returns all issues for a given repository
|
||||
func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Issue, error) {
|
||||
func (c *Client) ListRepoIssues(owner, repo string, opt structs.ListIssueOption) ([]*Issue, error) {
|
||||
issues := make([]*Issue, 0, 10)
|
||||
return issues, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues?page=%d", owner, repo, opt.Page), nil, nil, &issues)
|
||||
}
|
||||
|
@ -88,25 +43,8 @@ func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, error) {
|
|||
return issue, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), nil, nil, issue)
|
||||
}
|
||||
|
||||
// CreateIssueOption options to create one issue
|
||||
type CreateIssueOption struct {
|
||||
// required:true
|
||||
Title string `json:"title" binding:"Required"`
|
||||
Body string `json:"body"`
|
||||
// username of assignee
|
||||
Assignee string `json:"assignee"`
|
||||
Assignees []string `json:"assignees"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
// milestone id
|
||||
Milestone int64 `json:"milestone"`
|
||||
// list of label ids
|
||||
Labels []int64 `json:"labels"`
|
||||
Closed bool `json:"closed"`
|
||||
}
|
||||
|
||||
// CreateIssue create a new issue for a given repository
|
||||
func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, error) {
|
||||
func (c *Client) CreateIssue(owner, repo string, opt structs.CreateIssueOption) (*Issue, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -116,20 +54,8 @@ func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue,
|
|||
jsonHeader, bytes.NewReader(body), issue)
|
||||
}
|
||||
|
||||
// EditIssueOption options for editing an issue
|
||||
type EditIssueOption struct {
|
||||
Title string `json:"title"`
|
||||
Body *string `json:"body"`
|
||||
Assignee *string `json:"assignee"`
|
||||
Assignees []string `json:"assignees"`
|
||||
Milestone *int64 `json:"milestone"`
|
||||
State *string `json:"state"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
}
|
||||
|
||||
// EditIssue modify an existing issue for a given repository
|
||||
func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption) (*Issue, error) {
|
||||
func (c *Client) EditIssue(owner, repo string, index int64, opt structs.EditIssueOption) (*Issue, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -154,23 +80,3 @@ func (c *Client) StopIssueStopWatch(owner, repo string, index int64) error {
|
|||
jsonHeader, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
// EditDeadlineOption options for creating a deadline
|
||||
type EditDeadlineOption struct {
|
||||
// required:true
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
}
|
||||
|
||||
// IssueDeadline represents an issue deadline
|
||||
// swagger:model
|
||||
type IssueDeadline struct {
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
}
|
||||
|
||||
// EditPriorityOption options for updating priority
|
||||
type EditPriorityOption struct {
|
||||
// required:true
|
||||
Priority int `json:"priority"`
|
||||
}
|
||||
|
|
|
@ -8,22 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Comment represents a comment on a commit or issue
|
||||
type Comment struct {
|
||||
ID int64 `json:"id"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
PRURL string `json:"pull_request_url"`
|
||||
IssueURL string `json:"issue_url"`
|
||||
Poster *User `json:"user"`
|
||||
Body string `json:"body"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
}
|
||||
// Comment is equal to structs.Comment
|
||||
type Comment = structs.Comment
|
||||
|
||||
// ListIssueComments list comments on an issue.
|
||||
func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment, error) {
|
||||
|
@ -37,14 +27,8 @@ func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) {
|
|||
return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments)
|
||||
}
|
||||
|
||||
// CreateIssueCommentOption options for creating a comment on an issue
|
||||
type CreateIssueCommentOption struct {
|
||||
// required:true
|
||||
Body string `json:"body" binding:"Required"`
|
||||
}
|
||||
|
||||
// CreateIssueComment create comment on an issue.
|
||||
func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateIssueCommentOption) (*Comment, error) {
|
||||
func (c *Client) CreateIssueComment(owner, repo string, index int64, opt structs.CreateIssueCommentOption) (*Comment, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -53,14 +37,8 @@ func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateI
|
|||
return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment)
|
||||
}
|
||||
|
||||
// EditIssueCommentOption options for editing a comment
|
||||
type EditIssueCommentOption struct {
|
||||
// required: true
|
||||
Body string `json:"body" binding:"Required"`
|
||||
}
|
||||
|
||||
// EditIssueComment edits an issue comment.
|
||||
func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, opt EditIssueCommentOption) (*Comment, error) {
|
||||
func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, opt structs.EditIssueCommentOption) (*Comment, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -8,17 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Label a label to an issue or a pr
|
||||
// swagger:model
|
||||
type Label struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
// example: 00aabb
|
||||
Color string `json:"color"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
// Label is equal to structs.Label
|
||||
type Label = structs.Label
|
||||
|
||||
// ListRepoLabels list labels of one repository
|
||||
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
|
||||
|
@ -33,17 +28,8 @@ func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) {
|
|||
return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label)
|
||||
}
|
||||
|
||||
// CreateLabelOption options for creating a label
|
||||
type CreateLabelOption struct {
|
||||
// required:true
|
||||
Name string `json:"name" binding:"Required"`
|
||||
// required:true
|
||||
// example: #00aabb
|
||||
Color string `json:"color" binding:"Required;Size(7)"`
|
||||
}
|
||||
|
||||
// CreateLabel create one label of repository
|
||||
func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, error) {
|
||||
func (c *Client) CreateLabel(owner, repo string, opt structs.CreateLabelOption) (*Label, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -53,14 +39,8 @@ func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label,
|
|||
jsonHeader, bytes.NewReader(body), label)
|
||||
}
|
||||
|
||||
// EditLabelOption options for editing a label
|
||||
type EditLabelOption struct {
|
||||
Name *string `json:"name"`
|
||||
Color *string `json:"color"`
|
||||
}
|
||||
|
||||
// EditLabel modify one label with options
|
||||
func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (*Label, error) {
|
||||
func (c *Client) EditLabel(owner, repo string, id int64, opt structs.EditLabelOption) (*Label, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -76,12 +56,6 @@ func (c *Client) DeleteLabel(owner, repo string, id int64) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// IssueLabelsOption a collection of labels
|
||||
type IssueLabelsOption struct {
|
||||
// list of label IDs
|
||||
Labels []int64 `json:"labels"`
|
||||
}
|
||||
|
||||
// GetIssueLabels get labels of one issue via issue id
|
||||
func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, error) {
|
||||
labels := make([]*Label, 0, 5)
|
||||
|
@ -89,7 +63,7 @@ func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, erro
|
|||
}
|
||||
|
||||
// AddIssueLabels add one or more labels to one issue
|
||||
func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) {
|
||||
func (c *Client) AddIssueLabels(owner, repo string, index int64, opt structs.IssueLabelsOption) ([]*Label, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -99,7 +73,7 @@ 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, error) {
|
||||
func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt structs.IssueLabelsOption) ([]*Label, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -8,22 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Milestone milestone is a collection of issues on one repository
|
||||
type Milestone struct {
|
||||
ID int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
State StateType `json:"state"`
|
||||
OpenIssues int `json:"open_issues"`
|
||||
ClosedIssues int `json:"closed_issues"`
|
||||
// swagger:strfmt date-time
|
||||
Closed *time.Time `json:"closed_at"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_on"`
|
||||
}
|
||||
// Milestone is equal to structs.Milestone
|
||||
type Milestone = structs.Milestone
|
||||
|
||||
// ListRepoMilestones list all the milestones of one repository
|
||||
func (c *Client) ListRepoMilestones(owner, repo string) ([]*Milestone, error) {
|
||||
|
@ -37,16 +27,8 @@ func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error)
|
|||
return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone)
|
||||
}
|
||||
|
||||
// CreateMilestoneOption options for creating a milestone
|
||||
type CreateMilestoneOption struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_on"`
|
||||
}
|
||||
|
||||
// CreateMilestone create one milestone with options
|
||||
func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) (*Milestone, error) {
|
||||
func (c *Client) CreateMilestone(owner, repo string, opt structs.CreateMilestoneOption) (*Milestone, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -55,16 +37,8 @@ func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption)
|
|||
return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone)
|
||||
}
|
||||
|
||||
// EditMilestoneOption options for editing a milestone
|
||||
type EditMilestoneOption struct {
|
||||
Title string `json:"title"`
|
||||
Description *string `json:"description"`
|
||||
State *string `json:"state"`
|
||||
Deadline *time.Time `json:"due_on"`
|
||||
}
|
||||
|
||||
// EditMilestone modify milestone with options
|
||||
func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOption) (*Milestone, error) {
|
||||
func (c *Client) EditMilestone(owner, repo string, id int64, opt structs.EditMilestoneOption) (*Milestone, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -8,22 +8,15 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// TrackedTime worked time for an issue / pr
|
||||
type TrackedTime struct {
|
||||
ID int64 `json:"id"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created"`
|
||||
// Time in seconds
|
||||
Time int64 `json:"time"`
|
||||
UserID int64 `json:"user_id"`
|
||||
IssueID int64 `json:"issue_id"`
|
||||
}
|
||||
// TrackedTime is equal to structs.TrackedTime
|
||||
type TrackedTime = structs.TrackedTime
|
||||
|
||||
// TrackedTimes represent a list of tracked times
|
||||
type TrackedTimes []*TrackedTime
|
||||
// TrackedTimes is equal to structs.TrackedTimes
|
||||
type TrackedTimes = structs.TrackedTimes
|
||||
|
||||
// GetUserTrackedTimes list tracked times of a user
|
||||
func (c *Client) GetUserTrackedTimes(owner, repo, user string) (TrackedTimes, error) {
|
||||
|
@ -43,15 +36,8 @@ func (c *Client) GetMyTrackedTimes() (TrackedTimes, error) {
|
|||
return times, c.getParsedResponse("GET", "/user/times", nil, nil, ×)
|
||||
}
|
||||
|
||||
// AddTimeOption options for adding time to an issue
|
||||
type AddTimeOption struct {
|
||||
// time in seconds
|
||||
// required: true
|
||||
Time int64 `json:"time" binding:"Required"`
|
||||
}
|
||||
|
||||
// AddTime adds time to issue with the given index
|
||||
func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*TrackedTime, error) {
|
||||
func (c *Client) AddTime(owner, repo string, index int64, opt structs.AddTimeOption) (*TrackedTime, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
// Copyright 2017 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 (
|
||||
"time"
|
||||
)
|
||||
|
||||
// LFSLock represent a lock
|
||||
// for use with the locks API.
|
||||
type LFSLock struct {
|
||||
ID string `json:"id"`
|
||||
Path string `json:"path"`
|
||||
LockedAt time.Time `json:"locked_at"`
|
||||
Owner *LFSLockOwner `json:"owner"`
|
||||
}
|
||||
|
||||
// LFSLockOwner represent a lock owner
|
||||
// for use with the locks API.
|
||||
type LFSLockOwner struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// LFSLockRequest contains the path of the lock to create
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#create-lock
|
||||
type LFSLockRequest struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// LFSLockResponse represent a lock created
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#create-lock
|
||||
type LFSLockResponse struct {
|
||||
Lock *LFSLock `json:"lock"`
|
||||
}
|
||||
|
||||
// LFSLockList represent a list of lock requested
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#list-locks
|
||||
type LFSLockList struct {
|
||||
Locks []*LFSLock `json:"locks"`
|
||||
Next string `json:"next_cursor,omitempty"`
|
||||
}
|
||||
|
||||
// LFSLockListVerify represent a list of lock verification requested
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#list-locks-for-verification
|
||||
type LFSLockListVerify struct {
|
||||
Ours []*LFSLock `json:"ours"`
|
||||
Theirs []*LFSLock `json:"theirs"`
|
||||
Next string `json:"next_cursor,omitempty"`
|
||||
}
|
||||
|
||||
// LFSLockError contains information on the error that occurs
|
||||
type LFSLockError struct {
|
||||
Message string `json:"message"`
|
||||
Lock *LFSLock `json:"lock,omitempty"`
|
||||
Documentation string `json:"documentation_url,omitempty"`
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
}
|
||||
|
||||
// LFSLockDeleteRequest contains params of a delete request
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#delete-lock
|
||||
type LFSLockDeleteRequest struct {
|
||||
Force bool `json:"force"`
|
||||
}
|
|
@ -4,49 +4,10 @@
|
|||
|
||||
package gitea
|
||||
|
||||
// SearchResults results of a successful search
|
||||
type SearchResults struct {
|
||||
OK bool `json:"ok"`
|
||||
Data []*Repository `json:"data"`
|
||||
}
|
||||
|
||||
// SearchError error of a failed search
|
||||
type SearchError struct {
|
||||
OK bool `json:"ok"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
// MarkdownOption markdown options
|
||||
type MarkdownOption struct {
|
||||
// Text markdown to render
|
||||
//
|
||||
// in: body
|
||||
Text string
|
||||
// Mode to render
|
||||
//
|
||||
// in: body
|
||||
Mode string
|
||||
// Context to render
|
||||
//
|
||||
// in: body
|
||||
Context string
|
||||
// Is it a wiki page ?
|
||||
//
|
||||
// in: body
|
||||
Wiki bool
|
||||
}
|
||||
|
||||
// MarkdownRender is a rendered markdown document
|
||||
// swagger:response MarkdownRender
|
||||
type MarkdownRender string
|
||||
|
||||
// ServerVersion wraps the version of the server
|
||||
type ServerVersion struct {
|
||||
Version string `json:"version"`
|
||||
}
|
||||
import "code.gitea.io/gitea/modules/structs"
|
||||
|
||||
// ServerVersion returns the version of the server
|
||||
func (c *Client) ServerVersion() (string, error) {
|
||||
v := ServerVersion{}
|
||||
v := structs.ServerVersion{}
|
||||
return v.Version, c.getParsedResponse("GET", "/api/v1/version", nil, nil, &v)
|
||||
}
|
||||
|
|
36
gitea/org.go
36
gitea/org.go
|
@ -8,19 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Organization represents an organization
|
||||
type Organization struct {
|
||||
ID int64 `json:"id"`
|
||||
UserName string `json:"username"`
|
||||
FullName string `json:"full_name"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
Description string `json:"description"`
|
||||
Website string `json:"website"`
|
||||
Location string `json:"location"`
|
||||
Visibility VisibleType `json:"visibility"`
|
||||
}
|
||||
// Organization is equal to structs.Organization
|
||||
type Organization = structs.Organization
|
||||
|
||||
// ListMyOrgs list all of current user's organizations
|
||||
func (c *Client) ListMyOrgs() ([]*Organization, error) {
|
||||
|
@ -40,27 +33,8 @@ func (c *Client) GetOrg(orgname string) (*Organization, error) {
|
|||
return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org)
|
||||
}
|
||||
|
||||
// CreateOrgOption options for creating an organization
|
||||
type CreateOrgOption struct {
|
||||
// required: true
|
||||
UserName string `json:"username" binding:"Required"`
|
||||
FullName string `json:"full_name"`
|
||||
Description string `json:"description"`
|
||||
Website string `json:"website"`
|
||||
Location string `json:"location"`
|
||||
Visibility VisibleType `json:"visibility"`
|
||||
}
|
||||
|
||||
// EditOrgOption options for editing an organization
|
||||
type EditOrgOption struct {
|
||||
FullName string `json:"full_name"`
|
||||
Description string `json:"description"`
|
||||
Website string `json:"website"`
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
// EditOrg modify one organization via options
|
||||
func (c *Client) EditOrg(orgname string, opt EditOrgOption) error {
|
||||
func (c *Client) EditOrg(orgname string, opt structs.EditOrgOption) error {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -8,15 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// AddOrgMembershipOption add user to organization options
|
||||
type AddOrgMembershipOption struct {
|
||||
Role string `json:"role" binding:"Required"`
|
||||
}
|
||||
|
||||
// AddOrgMembership add some one to an organization's member
|
||||
func (c *Client) AddOrgMembership(org, user string, opt AddOrgMembershipOption) error {
|
||||
func (c *Client) AddOrgMembership(org, user string, opt structs.AddOrgMembershipOption) error {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2018 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
|
||||
|
||||
// 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"`
|
||||
// enum: none,read,write,admin,owner
|
||||
Permission string `json:"permission"`
|
||||
// enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki
|
||||
Units []string `json:"units"`
|
||||
}
|
||||
|
||||
// CreateTeamOption options for creating a team
|
||||
type CreateTeamOption struct {
|
||||
// required: true
|
||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
|
||||
Description string `json:"description" binding:"MaxSize(255)"`
|
||||
// enum: read,write,admin
|
||||
Permission string `json:"permission"`
|
||||
// enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki
|
||||
Units []string `json:"units"`
|
||||
}
|
||||
|
||||
// EditTeamOption options for editing a team
|
||||
type EditTeamOption struct {
|
||||
// required: true
|
||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
|
||||
Description string `json:"description" binding:"MaxSize(255)"`
|
||||
// enum: read,write,admin
|
||||
Permission string `json:"permission"`
|
||||
// enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki
|
||||
Units []string `json:"units"`
|
||||
}
|
|
@ -4,44 +4,10 @@
|
|||
|
||||
package gitea
|
||||
|
||||
// VisibleType defines the visibility (Organization only)
|
||||
type VisibleType int
|
||||
|
||||
const (
|
||||
// VisibleTypePublic Visible for everyone
|
||||
VisibleTypePublic VisibleType = iota
|
||||
|
||||
// VisibleTypeLimited Visible for every connected user
|
||||
VisibleTypeLimited
|
||||
|
||||
// VisibleTypePrivate Visible only for organization's members
|
||||
VisibleTypePrivate
|
||||
)
|
||||
|
||||
// VisibilityModes is a map of org Visibility types
|
||||
var VisibilityModes = map[string]VisibleType{
|
||||
"public": VisibleTypePublic,
|
||||
"limited": VisibleTypeLimited,
|
||||
"private": VisibleTypePrivate,
|
||||
}
|
||||
|
||||
// IsPublic returns true if VisibleType is public
|
||||
func (vt VisibleType) IsPublic() bool {
|
||||
return vt == VisibleTypePublic
|
||||
}
|
||||
|
||||
// IsLimited returns true if VisibleType is limited
|
||||
func (vt VisibleType) IsLimited() bool {
|
||||
return vt == VisibleTypeLimited
|
||||
}
|
||||
|
||||
// IsPrivate returns true if VisibleType is private
|
||||
func (vt VisibleType) IsPrivate() bool {
|
||||
return vt == VisibleTypePrivate
|
||||
}
|
||||
import "code.gitea.io/gitea/modules/structs"
|
||||
|
||||
// ExtractKeysFromMapString provides a slice of keys from map
|
||||
func ExtractKeysFromMapString(in map[string]VisibleType) (keys []string) {
|
||||
func ExtractKeysFromMapString(in map[string]structs.VisibleType) (keys []string) {
|
||||
for k := range in {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
|
|
@ -8,67 +8,15 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// PullRequest represents a pull request
|
||||
type PullRequest struct {
|
||||
ID int64 `json:"id"`
|
||||
URL string `json:"url"`
|
||||
Index int64 `json:"number"`
|
||||
Poster *User `json:"user"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Labels []*Label `json:"labels"`
|
||||
Milestone *Milestone `json:"milestone"`
|
||||
Assignee *User `json:"assignee"`
|
||||
Assignees []*User `json:"assignees"`
|
||||
State StateType `json:"state"`
|
||||
Comments int `json:"comments"`
|
||||
|
||||
HTMLURL string `json:"html_url"`
|
||||
DiffURL string `json:"diff_url"`
|
||||
PatchURL string `json:"patch_url"`
|
||||
|
||||
Mergeable bool `json:"mergeable"`
|
||||
HasMerged bool `json:"merged"`
|
||||
// swagger:strfmt date-time
|
||||
Merged *time.Time `json:"merged_at"`
|
||||
MergedCommitID *string `json:"merge_commit_sha"`
|
||||
MergedBy *User `json:"merged_by"`
|
||||
|
||||
Base *PRBranchInfo `json:"base"`
|
||||
Head *PRBranchInfo `json:"head"`
|
||||
MergeBase string `json:"merge_base"`
|
||||
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
|
||||
// swagger:strfmt date-time
|
||||
Created *time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated *time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
Closed *time.Time `json:"closed_at"`
|
||||
}
|
||||
|
||||
// PRBranchInfo information about a branch
|
||||
type PRBranchInfo struct {
|
||||
Name string `json:"label"`
|
||||
Ref string `json:"ref"`
|
||||
Sha string `json:"sha"`
|
||||
RepoID int64 `json:"repo_id"`
|
||||
Repository *Repository `json:"repo"`
|
||||
}
|
||||
|
||||
// ListPullRequestsOptions options for listing pull requests
|
||||
type ListPullRequestsOptions struct {
|
||||
Page int `json:"page"`
|
||||
State string `json:"state"`
|
||||
}
|
||||
// PullRequest is equal to structs.PullRequest
|
||||
type PullRequest = structs.PullRequest
|
||||
|
||||
// ListRepoPullRequests list PRs of one repository
|
||||
func (c *Client) ListRepoPullRequests(owner, repo string, opt ListPullRequestsOptions) ([]*PullRequest, error) {
|
||||
func (c *Client) ListRepoPullRequests(owner, repo string, opt structs.ListPullRequestsOptions) ([]*PullRequest, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -83,22 +31,8 @@ func (c *Client) GetPullRequest(owner, repo string, index int64) (*PullRequest,
|
|||
return pr, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d", owner, repo, index), nil, nil, pr)
|
||||
}
|
||||
|
||||
// CreatePullRequestOption options when creating a pull request
|
||||
type CreatePullRequestOption struct {
|
||||
Head string `json:"head" binding:"Required"`
|
||||
Base string `json:"base" binding:"Required"`
|
||||
Title string `json:"title" binding:"Required"`
|
||||
Body string `json:"body"`
|
||||
Assignee string `json:"assignee"`
|
||||
Assignees []string `json:"assignees"`
|
||||
Milestone int64 `json:"milestone"`
|
||||
Labels []int64 `json:"labels"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
}
|
||||
|
||||
// CreatePullRequest create pull request with options
|
||||
func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOption) (*PullRequest, error) {
|
||||
func (c *Client) CreatePullRequest(owner, repo string, opt structs.CreatePullRequestOption) (*PullRequest, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -108,21 +42,8 @@ func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOpti
|
|||
jsonHeader, bytes.NewReader(body), pr)
|
||||
}
|
||||
|
||||
// EditPullRequestOption options when modify pull request
|
||||
type EditPullRequestOption struct {
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Assignee string `json:"assignee"`
|
||||
Assignees []string `json:"assignees"`
|
||||
Milestone int64 `json:"milestone"`
|
||||
Labels []int64 `json:"labels"`
|
||||
State *string `json:"state"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
}
|
||||
|
||||
// EditPullRequest modify pull request with PR id and options
|
||||
func (c *Client) EditPullRequest(owner, repo string, index int64, opt EditPullRequestOption) (*PullRequest, error) {
|
||||
func (c *Client) EditPullRequest(owner, repo string, index int64, opt structs.EditPullRequestOption) (*PullRequest, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -147,5 +68,4 @@ func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, err
|
|||
}
|
||||
|
||||
return statusCode == 204, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -8,28 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Release represents a repository release
|
||||
type Release struct {
|
||||
ID int64 `json:"id"`
|
||||
TagName string `json:"tag_name"`
|
||||
Target string `json:"target_commitish"`
|
||||
Title string `json:"name"`
|
||||
Note string `json:"body"`
|
||||
URL string `json:"url"`
|
||||
TarURL string `json:"tarball_url"`
|
||||
ZipURL string `json:"zipball_url"`
|
||||
IsDraft bool `json:"draft"`
|
||||
IsPrerelease bool `json:"prerelease"`
|
||||
// swagger:strfmt date-time
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
PublishedAt time.Time `json:"published_at"`
|
||||
Publisher *User `json:"author"`
|
||||
Attachments []*Attachment `json:"assets"`
|
||||
}
|
||||
// Release is equal to structs.Release
|
||||
type Release = structs.Release
|
||||
|
||||
// ListReleases list releases of a repository
|
||||
func (c *Client) ListReleases(user, repo string) ([]*Release, error) {
|
||||
|
@ -49,19 +33,8 @@ func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) {
|
|||
return r, err
|
||||
}
|
||||
|
||||
// CreateReleaseOption options when creating a release
|
||||
type CreateReleaseOption struct {
|
||||
// required: true
|
||||
TagName string `json:"tag_name" binding:"Required"`
|
||||
Target string `json:"target_commitish"`
|
||||
Title string `json:"name"`
|
||||
Note string `json:"body"`
|
||||
IsDraft bool `json:"draft"`
|
||||
IsPrerelease bool `json:"prerelease"`
|
||||
}
|
||||
|
||||
// CreateRelease create a release
|
||||
func (c *Client) CreateRelease(user, repo string, form CreateReleaseOption) (*Release, error) {
|
||||
func (c *Client) CreateRelease(user, repo string, form structs.CreateReleaseOption) (*Release, error) {
|
||||
body, err := json.Marshal(form)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -73,18 +46,8 @@ func (c *Client) CreateRelease(user, repo string, form CreateReleaseOption) (*Re
|
|||
return r, err
|
||||
}
|
||||
|
||||
// EditReleaseOption options when editing a release
|
||||
type EditReleaseOption struct {
|
||||
TagName string `json:"tag_name"`
|
||||
Target string `json:"target_commitish"`
|
||||
Title string `json:"name"`
|
||||
Note string `json:"body"`
|
||||
IsDraft *bool `json:"draft"`
|
||||
IsPrerelease *bool `json:"prerelease"`
|
||||
}
|
||||
|
||||
// EditRelease edit a release
|
||||
func (c *Client) EditRelease(user, repo string, id int64, form EditReleaseOption) (*Release, error) {
|
||||
func (c *Client) EditRelease(user, repo string, id int64, form structs.EditReleaseOption) (*Release, error) {
|
||||
body, err := json.Marshal(form)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
124
gitea/repo.go
124
gitea/repo.go
|
@ -8,45 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Permission represents a set of permissions
|
||||
type Permission struct {
|
||||
Admin bool `json:"admin"`
|
||||
Push bool `json:"push"`
|
||||
Pull bool `json:"pull"`
|
||||
}
|
||||
|
||||
// Repository represents a repository
|
||||
type Repository struct {
|
||||
ID int64 `json:"id"`
|
||||
Owner *User `json:"owner"`
|
||||
Name string `json:"name"`
|
||||
FullName string `json:"full_name"`
|
||||
Description string `json:"description"`
|
||||
Empty bool `json:"empty"`
|
||||
Private bool `json:"private"`
|
||||
Fork bool `json:"fork"`
|
||||
Parent *Repository `json:"parent"`
|
||||
Mirror bool `json:"mirror"`
|
||||
Size int `json:"size"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
SSHURL string `json:"ssh_url"`
|
||||
CloneURL string `json:"clone_url"`
|
||||
Website string `json:"website"`
|
||||
Stars int `json:"stars_count"`
|
||||
Forks int `json:"forks_count"`
|
||||
Watchers int `json:"watchers_count"`
|
||||
OpenIssues int `json:"open_issues_count"`
|
||||
DefaultBranch string `json:"default_branch"`
|
||||
Archived bool `json:"archived"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
Permissions *Permission `json:"permissions,omitempty"`
|
||||
}
|
||||
// Repository is equal to structs.Repository
|
||||
type Repository = structs.Repository
|
||||
|
||||
// ListMyRepos lists all repositories for the authenticated user that has access to.
|
||||
func (c *Client) ListMyRepos() ([]*Repository, error) {
|
||||
|
@ -66,30 +33,8 @@ func (c *Client) ListOrgRepos(org string) ([]*Repository, error) {
|
|||
return repos, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/repos", org), nil, nil, &repos)
|
||||
}
|
||||
|
||||
// CreateRepoOption options when creating repository
|
||||
// swagger:model
|
||||
type CreateRepoOption struct {
|
||||
// Name of the repository to create
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
||||
// Description of the repository to create
|
||||
Description string `json:"description" binding:"MaxSize(255)"`
|
||||
// Whether the repository is private
|
||||
Private bool `json:"private"`
|
||||
// Whether the repository should be auto-intialized?
|
||||
AutoInit bool `json:"auto_init"`
|
||||
// Gitignores to use
|
||||
Gitignores string `json:"gitignores"`
|
||||
// License to use
|
||||
License string `json:"license"`
|
||||
// Readme of the repository to create
|
||||
Readme string `json:"readme"`
|
||||
}
|
||||
|
||||
// CreateRepo creates a repository for authenticated user.
|
||||
func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, error) {
|
||||
func (c *Client) CreateRepo(opt structs.CreateRepoOption) (*Repository, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -99,7 +44,7 @@ func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, error) {
|
|||
}
|
||||
|
||||
// CreateOrgRepo creates an organization repository for authenticated user.
|
||||
func (c *Client) CreateOrgRepo(org string, opt CreateRepoOption) (*Repository, error) {
|
||||
func (c *Client) CreateOrgRepo(org string, opt structs.CreateRepoOption) (*Repository, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -114,46 +59,8 @@ func (c *Client) GetRepo(owner, reponame string) (*Repository, error) {
|
|||
return repo, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s", owner, reponame), nil, nil, repo)
|
||||
}
|
||||
|
||||
// EditRepoOption options when editing a repository's properties
|
||||
// swagger:model
|
||||
type EditRepoOption struct {
|
||||
// Name of the repository
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
Name *string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
||||
// A short description of the repository.
|
||||
Description *string `json:"description,omitempty" binding:"MaxSize(255)"`
|
||||
// A URL with more information about the repository.
|
||||
Website *string `json:"website,omitempty" binding:"MaxSize(255)"`
|
||||
// Either `true` to make the repository private or `false` to make it public.
|
||||
// Note: You will get a 422 error if the organization restricts changing repository visibility to organization
|
||||
// owners and a non-owner tries to change the value of private.
|
||||
Private *bool `json:"private,omitempty"`
|
||||
// Either `true` to enable issues for this repository or `false` to disable them.
|
||||
EnableIssues *bool `json:"enable_issues,omitempty"`
|
||||
// Either `true` to enable the wiki for this repository or `false` to disable it.
|
||||
EnableWiki *bool `json:"enable_wiki,omitempty"`
|
||||
// Updates the default branch for this repository.
|
||||
DefaultBranch *string `json:"default_branch,omitempty"`
|
||||
// Either `true` to allow pull requests, or `false` to prevent pull request.
|
||||
EnablePullRequests *bool `json:"enable_pull_requests,omitempty"`
|
||||
// Either `true` to ignore whitepace for conflicts, or `false` to not ignore whitespace. `enabled_pull_requests` must be `true`.
|
||||
IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace,omitempty"`
|
||||
// Either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `enabled_pull_requests` must be `true`.
|
||||
AllowMerge *bool `json:"allow_merge_commits,omitempty"`
|
||||
// Either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. `enabled_pull_requests` must be `true`.
|
||||
AllowRebase *bool `json:"allow_rebase,omitempty"`
|
||||
// Either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits. `enabled_pull_requests` must be `true`.
|
||||
AllowRebaseMerge *bool `json:"allow_rebase_explicit,omitempty"`
|
||||
// Either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. `enabled_pull_requests` must be `true`.
|
||||
AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"`
|
||||
// `true` to archive this repository. Note: You cannot unarchive repositories through the API.
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
}
|
||||
|
||||
// EditRepo edit the properties of a repository
|
||||
func (c *Client) EditRepo(owner, reponame string, opt EditRepoOption) (*Repository, error) {
|
||||
func (c *Client) EditRepo(owner, reponame string, opt structs.EditRepoOption) (*Repository, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -168,27 +75,12 @@ func (c *Client) DeleteRepo(owner, repo string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// MigrateRepoOption options for migrating a repository from an external service
|
||||
type MigrateRepoOption struct {
|
||||
// required: true
|
||||
CloneAddr string `json:"clone_addr" binding:"Required"`
|
||||
AuthUsername string `json:"auth_username"`
|
||||
AuthPassword string `json:"auth_password"`
|
||||
// required: true
|
||||
UID int `json:"uid" binding:"Required"`
|
||||
// required: true
|
||||
RepoName string `json:"repo_name" binding:"Required"`
|
||||
Mirror bool `json:"mirror"`
|
||||
Private bool `json:"private"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// MigrateRepo migrates a repository from other Git hosting sources for the
|
||||
// authenticated user.
|
||||
//
|
||||
// To migrate a repository for a organization, the authenticated user must be a
|
||||
// owner of the specified organization.
|
||||
func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, error) {
|
||||
func (c *Client) MigrateRepo(opt structs.MigrateRepoOption) (*Repository, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -6,13 +6,12 @@ package gitea
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Branch represents a repository branch
|
||||
type Branch struct {
|
||||
Name string `json:"name"`
|
||||
Commit *PayloadCommit `json:"commit"`
|
||||
}
|
||||
// Branch is equal to structs.Branch
|
||||
type Branch = structs.Branch
|
||||
|
||||
// ListRepoBranches list all the branches of one repository
|
||||
func (c *Client) ListRepoBranches(user, repo string) ([]*Branch, error) {
|
||||
|
|
|
@ -8,6 +8,8 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// ListCollaborators list a repository's collaborators
|
||||
|
@ -33,13 +35,8 @@ func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
|
||||
// AddCollaboratorOption options when adding a user as a collaborator of a repository
|
||||
type AddCollaboratorOption struct {
|
||||
Permission *string `json:"permission"`
|
||||
}
|
||||
|
||||
// AddCollaborator add some user as a collaborator of a repository
|
||||
func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollaboratorOption) error {
|
||||
func (c *Client) AddCollaborator(user, repo, collaborator string, opt structs.AddCollaboratorOption) error {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -7,45 +7,12 @@ package gitea
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Identity for a person's identity like an author or committer
|
||||
type Identity struct {
|
||||
Name string `json:"name" binding:"MaxSize(100)"`
|
||||
// swagger:strfmt email
|
||||
Email string `json:"email" binding:"MaxSize(254)"`
|
||||
}
|
||||
|
||||
// CommitMeta contains meta information of a commit in terms of API.
|
||||
type CommitMeta struct {
|
||||
URL string `json:"url"`
|
||||
SHA string `json:"sha"`
|
||||
}
|
||||
|
||||
// CommitUser contains information of a user in the context of a commit.
|
||||
type CommitUser struct {
|
||||
Identity
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
// RepoCommit contains information of a commit in the context of a repository.
|
||||
type RepoCommit struct {
|
||||
URL string `json:"url"`
|
||||
Author *CommitUser `json:"author"`
|
||||
Committer *CommitUser `json:"committer"`
|
||||
Message string `json:"message"`
|
||||
Tree *CommitMeta `json:"tree"`
|
||||
}
|
||||
|
||||
// Commit contains information generated from a Git commit.
|
||||
type Commit struct {
|
||||
*CommitMeta
|
||||
HTMLURL string `json:"html_url"`
|
||||
RepoCommit *RepoCommit `json:"commit"`
|
||||
Author *User `json:"author"`
|
||||
Committer *User `json:"committer"`
|
||||
Parents []*CommitMeta `json:"parents"`
|
||||
}
|
||||
// Commit is equal to structs.Commit
|
||||
type Commit = structs.Commit
|
||||
|
||||
// GetSingleCommit returns a single commit
|
||||
func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) {
|
||||
|
|
|
@ -14,77 +14,3 @@ import (
|
|||
func (c *Client) GetFile(user, repo, ref, tree string) ([]byte, error) {
|
||||
return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/raw/%s/%s", user, repo, ref, tree), nil, nil)
|
||||
}
|
||||
|
||||
// FileOptions options for all file APIs
|
||||
type FileOptions struct {
|
||||
Message string `json:"message" binding:"Required"`
|
||||
BranchName string `json:"branch"`
|
||||
NewBranchName string `json:"new_branch"`
|
||||
Author Identity `json:"author"`
|
||||
Committer Identity `json:"committer"`
|
||||
}
|
||||
|
||||
// CreateFileOptions options for creating files
|
||||
type CreateFileOptions struct {
|
||||
FileOptions
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// DeleteFileOptions options for deleting files (used for other File structs below)
|
||||
type DeleteFileOptions struct {
|
||||
FileOptions
|
||||
SHA string `json:"sha" binding:"Required"`
|
||||
}
|
||||
|
||||
// UpdateFileOptions options for updating files
|
||||
type UpdateFileOptions struct {
|
||||
DeleteFileOptions
|
||||
Content string `json:"content"`
|
||||
FromPath string `json:"from_path" binding:"MaxSize(500)"`
|
||||
}
|
||||
|
||||
// FileLinksResponse contains the links for a repo's file
|
||||
type FileLinksResponse struct {
|
||||
Self string `json:"url"`
|
||||
GitURL string `json:"git_url"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
}
|
||||
|
||||
// FileContentResponse contains information about a repo's file stats and content
|
||||
type FileContentResponse struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
SHA string `json:"sha"`
|
||||
Size int64 `json:"size"`
|
||||
URL string `json:"url"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
GitURL string `json:"git_url"`
|
||||
DownloadURL string `json:"download_url"`
|
||||
Type string `json:"type"`
|
||||
Links *FileLinksResponse `json:"_links"`
|
||||
}
|
||||
|
||||
// FileCommitResponse contains information generated from a Git commit for a repo's file.
|
||||
type FileCommitResponse struct {
|
||||
CommitMeta
|
||||
HTMLURL string `json:"html_url"`
|
||||
Author *CommitUser `json:"author"`
|
||||
Committer *CommitUser `json:"committer"`
|
||||
Parents []*CommitMeta `json:"parents"`
|
||||
Message string `json:"message"`
|
||||
Tree *CommitMeta `json:"tree"`
|
||||
}
|
||||
|
||||
// FileResponse contains information about a repo's file
|
||||
type FileResponse struct {
|
||||
Content *FileContentResponse `json:"content"`
|
||||
Commit *FileCommitResponse `json:"commit"`
|
||||
Verification *PayloadCommitVerification `json:"verification"`
|
||||
}
|
||||
|
||||
// FileDeleteResponse contains information about a repo's file that was deleted
|
||||
type FileDeleteResponse struct {
|
||||
Content interface{} `json:"content"` // to be set to nil
|
||||
Commit *FileCommitResponse `json:"commit"`
|
||||
Verification *PayloadCommitVerification `json:"verification"`
|
||||
}
|
||||
|
|
|
@ -8,22 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// DeployKey a deploy key
|
||||
type DeployKey struct {
|
||||
ID int64 `json:"id"`
|
||||
KeyID int64 `json:"key_id"`
|
||||
Key string `json:"key"`
|
||||
URL string `json:"url"`
|
||||
Title string `json:"title"`
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
ReadOnly bool `json:"read_only"`
|
||||
Repository *Repository `json:"repository,omitempty"`
|
||||
}
|
||||
// DeployKey is equal to structs.DeployKey
|
||||
type DeployKey = structs.DeployKey
|
||||
|
||||
// ListDeployKeys list all the deploy keys of one repository
|
||||
func (c *Client) ListDeployKeys(user, repo string) ([]*DeployKey, error) {
|
||||
|
@ -37,26 +27,8 @@ func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error
|
|||
return key, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys/%d", user, repo, keyID), nil, nil, &key)
|
||||
}
|
||||
|
||||
// CreateKeyOption options when creating a key
|
||||
type CreateKeyOption struct {
|
||||
// Title of the key to add
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
Title string `json:"title" binding:"Required"`
|
||||
// An armored SSH key to add
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
Key string `json:"key" binding:"Required"`
|
||||
// Describe if the key has only read access or read/write
|
||||
//
|
||||
// required: false
|
||||
ReadOnly bool `json:"read_only"`
|
||||
}
|
||||
|
||||
// CreateDeployKey options when create one deploy key
|
||||
func (c *Client) CreateDeployKey(user, repo string, opt CreateKeyOption) (*DeployKey, error) {
|
||||
func (c *Client) CreateDeployKey(user, repo string, opt structs.CreateKeyOption) (*DeployKey, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -9,21 +9,12 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Reference represents a Git reference.
|
||||
type Reference struct {
|
||||
Ref string `json:"ref"`
|
||||
URL string `json:"url"`
|
||||
Object *GitObject `json:"object"`
|
||||
}
|
||||
|
||||
// GitObject represents a Git object.
|
||||
type GitObject struct {
|
||||
Type string `json:"type"`
|
||||
SHA string `json:"sha"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
// Reference is equal to structs.Reference
|
||||
type Reference = structs.Reference
|
||||
|
||||
// GetRepoRef get one ref's information of one repository
|
||||
func (c *Client) GetRepoRef(user, repo, ref string) (*Reference, error) {
|
||||
|
|
|
@ -6,18 +6,12 @@ package gitea
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Tag represents a repository tag
|
||||
type Tag struct {
|
||||
Name string `json:"name"`
|
||||
Commit struct {
|
||||
SHA string `json:"sha"`
|
||||
URL string `json:"url"`
|
||||
} `json:"commit"`
|
||||
ZipballURL string `json:"zipball_url"`
|
||||
TarballURL string `json:"tarball_url"`
|
||||
}
|
||||
// Tag is equal to structs.Tag
|
||||
type Tag = structs.Tag
|
||||
|
||||
// ListRepoTags list all the branches of one repository
|
||||
func (c *Client) ListRepoTags(user, repo string) ([]*Tag, error) {
|
||||
|
|
|
@ -6,32 +6,14 @@ package gitea
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// GitEntry represents a git tree
|
||||
type GitEntry struct {
|
||||
Path string `json:"path"`
|
||||
Mode string `json:"mode"`
|
||||
Type string `json:"type"`
|
||||
Size int64 `json:"size"`
|
||||
SHA string `json:"sha"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// GitTreeResponse returns a git tree
|
||||
type GitTreeResponse struct {
|
||||
SHA string `json:"sha"`
|
||||
URL string `json:"url"`
|
||||
Entries []GitEntry `json:"tree"`
|
||||
Truncated bool `json:"truncated"`
|
||||
Page int `json:"page"`
|
||||
TotalCount int `json:"total_count"`
|
||||
}
|
||||
|
||||
// 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, error) {
|
||||
var trees GitTreeResponse
|
||||
func (c *Client) GetTrees(user, repo, ref string, recursive bool) (*structs.GitTreeResponse, error) {
|
||||
var trees structs.GitTreeResponse
|
||||
var path = fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref)
|
||||
if recursive {
|
||||
path += "?recursive=1"
|
||||
|
|
|
@ -7,18 +7,12 @@ package gitea
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// WatchInfo represents an API watch status of one repository
|
||||
type WatchInfo struct {
|
||||
Subscribed bool `json:"subscribed"`
|
||||
Ignored bool `json:"ignored"`
|
||||
Reason interface{} `json:"reason"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
URL string `json:"url"`
|
||||
RepositoryURL string `json:"repository_url"`
|
||||
}
|
||||
// WatchInfo is equal to structs.WatchInfo
|
||||
type WatchInfo = structs.WatchInfo
|
||||
|
||||
// GetWatchedRepos list all the watched repos of user
|
||||
func (c *Client) GetWatchedRepos(user, pass string) ([]*Repository, error) {
|
||||
|
|
|
@ -8,69 +8,17 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// StatusState holds the state of a Status
|
||||
// It can be "pending", "success", "error", "failure", and "warning"
|
||||
type StatusState string
|
||||
|
||||
const (
|
||||
// StatusPending is for when the Status is Pending
|
||||
StatusPending StatusState = "pending"
|
||||
// StatusSuccess is for when the Status is Success
|
||||
StatusSuccess StatusState = "success"
|
||||
// StatusError is for when the Status is Error
|
||||
StatusError StatusState = "error"
|
||||
// StatusFailure is for when the Status is Failure
|
||||
StatusFailure StatusState = "failure"
|
||||
// StatusWarning is for when the Status is Warning
|
||||
StatusWarning StatusState = "warning"
|
||||
)
|
||||
|
||||
// Status holds a single Status of a single Commit
|
||||
type Status struct {
|
||||
ID int64 `json:"id"`
|
||||
State StatusState `json:"status"`
|
||||
TargetURL string `json:"target_url"`
|
||||
Description string `json:"description"`
|
||||
URL string `json:"url"`
|
||||
Context string `json:"context"`
|
||||
Creator *User `json:"creator"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// CombinedStatus holds the combined state of several statuses for a single commit
|
||||
type CombinedStatus struct {
|
||||
State StatusState `json:"state"`
|
||||
SHA string `json:"sha"`
|
||||
TotalCount int `json:"total_count"`
|
||||
Statuses []*Status `json:"statuses"`
|
||||
Repository *Repository `json:"repository"`
|
||||
CommitURL string `json:"commit_url"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// CreateStatusOption holds the information needed to create a new Status for a Commit
|
||||
type CreateStatusOption struct {
|
||||
State StatusState `json:"state"`
|
||||
TargetURL string `json:"target_url"`
|
||||
Description string `json:"description"`
|
||||
Context string `json:"context"`
|
||||
}
|
||||
|
||||
// ListStatusesOption holds pagination information
|
||||
type ListStatusesOption struct {
|
||||
Page int
|
||||
}
|
||||
// Status is equal to structs.Status
|
||||
type Status = structs.Status
|
||||
|
||||
// CreateStatus creates a new Status for a given Commit
|
||||
//
|
||||
// POST /repos/:owner/:repo/statuses/:sha
|
||||
func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption) (*Status, error) {
|
||||
func (c *Client) CreateStatus(owner, repo, sha string, opts structs.CreateStatusOption) (*Status, error) {
|
||||
body, err := json.Marshal(&opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -83,15 +31,15 @@ func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption)
|
|||
// ListStatuses returns all statuses for a given Commit
|
||||
//
|
||||
// GET /repos/:owner/:repo/commits/:ref/statuses
|
||||
func (c *Client) ListStatuses(owner, repo, sha string, opts ListStatusesOption) ([]*Status, error) {
|
||||
statuses := make([]*Status, 0, 10)
|
||||
func (c *Client) ListStatuses(owner, repo, sha string, opts structs.ListStatusesOption) ([]*Status, error) {
|
||||
statuses := make([]*structs.Status, 0, 10)
|
||||
return statuses, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/statuses?page=%d", owner, repo, sha, opts.Page), nil, nil, &statuses)
|
||||
}
|
||||
|
||||
// GetCombinedStatus returns the CombinedStatus for a given Commit
|
||||
//
|
||||
// GET /repos/:owner/:repo/commits/:ref/status
|
||||
func (c *Client) GetCombinedStatus(owner, repo, sha string) (*CombinedStatus, error) {
|
||||
status := &CombinedStatus{}
|
||||
func (c *Client) GetCombinedStatus(owner, repo, sha string) (*structs.CombinedStatus, error) {
|
||||
status := &structs.CombinedStatus{}
|
||||
return status, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/status", owner, repo, sha), nil, nil, status)
|
||||
}
|
||||
|
|
|
@ -5,38 +5,13 @@
|
|||
package gitea
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// User represents a user
|
||||
// swagger:model
|
||||
type User struct {
|
||||
// the user's id
|
||||
ID int64 `json:"id"`
|
||||
// the user's username
|
||||
UserName string `json:"login"`
|
||||
// the user's full name
|
||||
FullName string `json:"full_name"`
|
||||
// swagger:strfmt email
|
||||
Email string `json:"email"`
|
||||
// URL to the user's avatar
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
// User locale
|
||||
Language string `json:"language"`
|
||||
// Is the user an administrator
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
||||
func (u User) MarshalJSON() ([]byte, error) {
|
||||
// Re-declaring User to avoid recursion
|
||||
type shadow User
|
||||
return json.Marshal(struct {
|
||||
shadow
|
||||
CompatUserName string `json:"username"`
|
||||
}{shadow(u), u.UserName})
|
||||
}
|
||||
// User is equal to structs.User
|
||||
type User = structs.User
|
||||
|
||||
// GetUserInfo get user info by user's name
|
||||
func (c *Client) GetUserInfo(user string) (*User, error) {
|
||||
|
|
|
@ -11,6 +11,8 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// BasicAuthEncode generate base64 of basic auth head
|
||||
|
@ -18,18 +20,8 @@ func BasicAuthEncode(user, pass string) string {
|
|||
return base64.StdEncoding.EncodeToString([]byte(user + ":" + pass))
|
||||
}
|
||||
|
||||
// AccessToken represents an API access token.
|
||||
// swagger:response AccessToken
|
||||
type AccessToken struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Token string `json:"sha1"`
|
||||
TokenLastEight string `json:"token_last_eight"`
|
||||
}
|
||||
|
||||
// AccessTokenList represents a list of API access token.
|
||||
// swagger:response AccessTokenList
|
||||
type AccessTokenList []*AccessToken
|
||||
// AccessToken is equal to structs.AccessToken
|
||||
type AccessToken = structs.AccessToken
|
||||
|
||||
// ListAccessTokens lista all the access tokens of user
|
||||
func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) {
|
||||
|
@ -38,14 +30,8 @@ func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) {
|
|||
http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, nil, &tokens)
|
||||
}
|
||||
|
||||
// CreateAccessTokenOption options when create access token
|
||||
// swagger:parameters userCreateToken
|
||||
type CreateAccessTokenOption struct {
|
||||
Name string `json:"name" binding:"Required"`
|
||||
}
|
||||
|
||||
// CreateAccessToken create one access token with options
|
||||
func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOption) (*AccessToken, error) {
|
||||
func (c *Client) CreateAccessToken(user, pass string, opt structs.CreateAccessTokenOption) (*AccessToken, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -7,15 +7,12 @@ package gitea
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// Email an email address belonging to a user
|
||||
type Email struct {
|
||||
// swagger:strfmt email
|
||||
Email string `json:"email"`
|
||||
Verified bool `json:"verified"`
|
||||
Primary bool `json:"primary"`
|
||||
}
|
||||
// Email is equal to structs.Email
|
||||
type Email = structs.Email
|
||||
|
||||
// ListEmails all the email addresses of user
|
||||
func (c *Client) ListEmails() ([]*Email, error) {
|
||||
|
@ -23,14 +20,8 @@ func (c *Client) ListEmails() ([]*Email, error) {
|
|||
return emails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails)
|
||||
}
|
||||
|
||||
// CreateEmailOption options when creating email addresses
|
||||
type CreateEmailOption struct {
|
||||
// email addresses to add
|
||||
Emails []string `json:"emails"`
|
||||
}
|
||||
|
||||
// AddEmail add one email to current user with options
|
||||
func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) {
|
||||
func (c *Client) AddEmail(opt structs.CreateEmailOption) ([]*Email, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -39,14 +30,8 @@ func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) {
|
|||
return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails)
|
||||
}
|
||||
|
||||
// DeleteEmailOption options when deleting email addresses
|
||||
type DeleteEmailOption struct {
|
||||
// email addresses to delete
|
||||
Emails []string `json:"emails"`
|
||||
}
|
||||
|
||||
// DeleteEmail delete one email of current users'
|
||||
func (c *Client) DeleteEmail(opt DeleteEmailOption) error {
|
||||
func (c *Client) DeleteEmail(opt structs.DeleteEmailOption) error {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -8,42 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// GPGKey a user GPG key to sign commit and tag in repository
|
||||
type GPGKey struct {
|
||||
ID int64 `json:"id"`
|
||||
PrimaryKeyID string `json:"primary_key_id"`
|
||||
KeyID string `json:"key_id"`
|
||||
PublicKey string `json:"public_key"`
|
||||
Emails []*GPGKeyEmail `json:"emails"`
|
||||
SubsKey []*GPGKey `json:"subkeys"`
|
||||
CanSign bool `json:"can_sign"`
|
||||
CanEncryptComms bool `json:"can_encrypt_comms"`
|
||||
CanEncryptStorage bool `json:"can_encrypt_storage"`
|
||||
CanCertify bool `json:"can_certify"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at,omitempty"`
|
||||
// swagger:strfmt date-time
|
||||
Expires time.Time `json:"expires_at,omitempty"`
|
||||
}
|
||||
|
||||
// GPGKeyEmail an email attached to a GPGKey
|
||||
// swagger:model GPGKeyEmail
|
||||
type GPGKeyEmail struct {
|
||||
Email string `json:"email"`
|
||||
Verified bool `json:"verified"`
|
||||
}
|
||||
|
||||
// CreateGPGKeyOption options create user GPG key
|
||||
type CreateGPGKeyOption struct {
|
||||
// An armored GPG key to add
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
ArmoredKey string `json:"armored_public_key" binding:"Required"`
|
||||
}
|
||||
// GPGKey is equal to structs.GPGKey
|
||||
type GPGKey = structs.GPGKey
|
||||
|
||||
// ListGPGKeys list all the GPG keys of the user
|
||||
func (c *Client) ListGPGKeys(user string) ([]*GPGKey, error) {
|
||||
|
@ -64,7 +34,7 @@ func (c *Client) GetGPGKey(keyID int64) (*GPGKey, error) {
|
|||
}
|
||||
|
||||
// CreateGPGKey create GPG key with options
|
||||
func (c *Client) CreateGPGKey(opt CreateGPGKeyOption) (*GPGKey, error) {
|
||||
func (c *Client) CreateGPGKey(opt structs.CreateGPGKeyOption) (*GPGKey, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -8,22 +8,12 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// PublicKey publickey is a user key to push code to repository
|
||||
type PublicKey struct {
|
||||
ID int64 `json:"id"`
|
||||
Key string `json:"key"`
|
||||
URL string `json:"url,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at,omitempty"`
|
||||
Owner *User `json:"user,omitempty"`
|
||||
ReadOnly bool `json:"read_only,omitempty"`
|
||||
KeyType string `json:"key_type,omitempty"`
|
||||
}
|
||||
// PublicKey is equal to structs.PublicKey
|
||||
type PublicKey = structs.PublicKey
|
||||
|
||||
// ListPublicKeys list all the public keys of the user
|
||||
func (c *Client) ListPublicKeys(user string) ([]*PublicKey, error) {
|
||||
|
@ -44,7 +34,7 @@ func (c *Client) GetPublicKey(keyID int64) (*PublicKey, error) {
|
|||
}
|
||||
|
||||
// CreatePublicKey create public key with options
|
||||
func (c *Client) CreatePublicKey(opt CreateKeyOption) (*PublicKey, error) {
|
||||
func (c *Client) CreatePublicKey(opt structs.CreateKeyOption) (*PublicKey, error) {
|
||||
body, err := json.Marshal(&opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
package gitea
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var jsonHeader = http.Header{"content-type": []string{"application/json"}}
|
||||
|
||||
// Bool return address of bool value
|
||||
func Bool(v bool) *bool {
|
||||
return &v
|
||||
}
|
||||
|
||||
// String return address of string value
|
||||
func String(v string) *string {
|
||||
return &v
|
||||
}
|
||||
|
||||
// Int64 return address of int64 value
|
||||
func Int64(v int64) *int64 {
|
||||
return &v
|
||||
}
|
Loading…
Reference in a new issue