diff --git a/Makefile b/Makefile index 4c06e8e..ccc89ac 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ fmt: .PHONY: vet vet: - go get code.gitea.io/gitea/modules/structs cd gitea && go vet ./... .PHONY: lint diff --git a/gitea/admin_org.go b/gitea/admin_org.go index 1029d49..9023bcf 100644 --- a/gitea/admin_org.go +++ b/gitea/admin_org.go @@ -9,8 +9,6 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" ) // AdminListOrgs lists all orgs @@ -20,7 +18,7 @@ func (c *Client) AdminListOrgs() ([]*Organization, error) { } // AdminCreateOrg create an organization -func (c *Client) AdminCreateOrg(user string, opt structs.CreateOrgOption) (*Organization, error) { +func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/admin_user.go b/gitea/admin_user.go index 36f96cf..51152dd 100644 --- a/gitea/admin_user.go +++ b/gitea/admin_user.go @@ -9,8 +9,6 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" ) // AdminListUsers lists all users @@ -19,8 +17,20 @@ func (c *Client) AdminListUsers() ([]*User, error) { return users, c.getParsedResponse("GET", "/admin/users", nil, nil, &users) } +// CreateUserOption create user options +type CreateUserOption struct { + SourceID int64 `json:"source_id"` + LoginName string `json:"login_name"` + Username string `json:"username"` + FullName string `json:"full_name"` + Email string `json:"email"` + Password string `json:"password"` + MustChangePassword *bool `json:"must_change_password"` + SendNotify bool `json:"send_notify"` +} + // AdminCreateUser create a user -func (c *Client) AdminCreateUser(opt structs.CreateUserOption) (*User, error) { +func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -29,8 +39,27 @@ func (c *Client) AdminCreateUser(opt structs.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"` + Email string `json:"email"` + Password string `json:"password"` + MustChangePassword *bool `json:"must_change_password"` + Website string `json:"website"` + Location string `json:"location"` + Active *bool `json:"active"` + Admin *bool `json:"admin"` + AllowGitHook *bool `json:"allow_git_hook"` + AllowImportLocal *bool `json:"allow_import_local"` + MaxRepoCreation *int `json:"max_repo_creation"` + ProhibitLogin *bool `json:"prohibit_login"` + AllowCreateOrganization *bool `json:"allow_create_organization"` +} + // AdminEditUser modify user informations -func (c *Client) AdminEditUser(user string, opt structs.EditUserOption) error { +func (c *Client) AdminEditUser(user string, opt EditUserOption) error { body, err := json.Marshal(&opt) if err != nil { return err @@ -46,7 +75,7 @@ func (c *Client) AdminDeleteUser(user string) error { } // AdminCreateUserPublicKey adds a public key for the user -func (c *Client) AdminCreateUserPublicKey(user string, opt structs.CreateKeyOption) (*PublicKey, error) { +func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/attachment.go b/gitea/attachment.go index 9bca47c..ca45195 100644 --- a/gitea/attachment.go +++ b/gitea/attachment.go @@ -10,12 +10,19 @@ import ( "io" "mime/multipart" "net/http" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// Attachment is equal to structs.Attachment -type Attachment = structs.Attachment +// Attachment a generic attachment +type Attachment struct { + ID int64 `json:"id"` + Name string `json:"name"` + Size int64 `json:"size"` + DownloadCount int64 `json:"download_count"` + Created time.Time `json:"created_at"` + UUID string `json:"uuid"` + DownloadURL string `json:"browser_download_url"` +} // ListReleaseAttachments list release's attachments func (c *Client) ListReleaseAttachments(user, repo string, release int64) ([]*Attachment, error) { @@ -60,8 +67,13 @@ func (c *Client) CreateReleaseAttachment(user, repo string, release int64, file return attachment, err } +// EditAttachmentOptions options for editing attachments +type EditAttachmentOptions struct { + Name string `json:"name"` +} + // EditReleaseAttachment updates the given attachment with the given options -func (c *Client) EditReleaseAttachment(user, repo string, release int64, attachment int64, form structs.EditAttachmentOptions) (*Attachment, error) { +func (c *Client) EditReleaseAttachment(user, repo string, release int64, attachment int64, form EditAttachmentOptions) (*Attachment, error) { body, err := json.Marshal(&form) if err != nil { return nil, err diff --git a/gitea/fork.go b/gitea/fork.go index 1d4938d..5722249 100644 --- a/gitea/fork.go +++ b/gitea/fork.go @@ -8,8 +8,6 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" ) // ListForks list a repository's forks @@ -21,8 +19,14 @@ 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 structs.CreateForkOption) (*Repository, error) { +func (c *Client) CreateFork(user, repo string, form CreateForkOption) (*Repository, error) { body, err := json.Marshal(form) if err != nil { return nil, err diff --git a/gitea/git_hook.go b/gitea/git_hook.go index d061a7f..089553f 100644 --- a/gitea/git_hook.go +++ b/gitea/git_hook.go @@ -8,18 +8,17 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" ) -// GitHook is equal to structs.GitHook -type GitHook = structs.GitHook - -// GitHookList is equal to structs.GitHookList -type GitHookList = structs.GitHookList +// GitHook represents a Git repository hook +type GitHook struct { + Name string `json:"name"` + IsActive bool `json:"is_active"` + Content string `json:"content,omitempty"` +} // ListRepoGitHooks list all the Git hooks of one repository -func (c *Client) ListRepoGitHooks(user, repo string) (GitHookList, error) { +func (c *Client) ListRepoGitHooks(user, repo string) ([]*GitHook, error) { hooks := make([]*GitHook, 0, 10) return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git", user, repo), nil, nil, &hooks) } @@ -30,8 +29,13 @@ 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 structs.EditGitHookOption) error { +func (c *Client) EditRepoGitHook(user, repo, id string, opt EditGitHookOption) error { body, err := json.Marshal(&opt) if err != nil { return err diff --git a/gitea/go.mod b/gitea/go.mod index 12ed4ee..4143739 100644 --- a/gitea/go.mod +++ b/gitea/go.mod @@ -1,5 +1,3 @@ module code.gitea.io/sdk/gitea go 1.12 - -require code.gitea.io/gitea v1.10.0-dev.0.20190711052757-a0820e09fbf7 diff --git a/gitea/go.sum b/gitea/go.sum index 71432ca..e69de29 100644 --- a/gitea/go.sum +++ b/gitea/go.sum @@ -1,263 +0,0 @@ -cloud.google.com/go v0.30.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -code.gitea.io/gitea v1.10.0-dev.0.20190711052757-a0820e09fbf7 h1:mmavl3m1OmiTywSQ9ixb7esGfyBT9c2/UHWthEjl+DU= -code.gitea.io/gitea v1.10.0-dev.0.20190711052757-a0820e09fbf7/go.mod h1:M4dnaQvrKfmOxBkO1b6dsaSM7IGbbuA9IzDMBkuKKWg= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -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-20190321035513-0fed4efef755/go.mod h1:voKvFVpXBJxdIPeqjoJuLK+UVcRlo/JLjeToGxPYu68= -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/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -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/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -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/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -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-20190121005146-b04fd42d9952/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -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.3/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/gliderlabs/ssh v0.2.2/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-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -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-20190710000913-8dc5911259df/go.mod h1:j9TJ+0nwUOWBvNnm0bheHIPFf3cC62EQo7n7O6PbjZA= -github.com/go-macaron/cors v0.0.0-20190309005821-6fd6a9bfe14e9/go.mod h1:utmMRnVIrXPSfA9MFcpIYKEpKawjKxf62vv62k4707E= -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.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -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.7.3-0.20190620151208-f1b4f8368459/go.mod h1:UK1YDlWscDspd23xW9HC24749jhvwO6riZ/HUt3gbHQ= -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.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/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-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -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/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/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.3.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.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -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/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/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -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.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.1.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/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/oliamb/cutter v0.2.2/go.mod h1:4BenG2/4GuRBDbVm/OPahDVqbrOemzpPiG5mi1iryBU= -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.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -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/httpfs v0.0.0-20190527155220-6a4d4a70508b/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= -github.com/shurcooL/sanitized_anchor_name v0.0.0-20160918041101-1dba4b3954bc/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= -github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d/go.mod h1:vq0tzqLRu6TS7Id0wMo2N5QzJoKedVeovOpHjnykSzY= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= -github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff/go.mod h1:KSQcGKpxUMHk3nbYzs/tIBAM2iDooCn0BmttHOJEbLs= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -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/objx v0.1.1/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.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= -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/crypto v0.0.0-20190122013713-64072686203f/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -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-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190502183928-7f726cade0ab/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -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/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/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-20180905080454-ebe1bf3edb33/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-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190620070143-6f217b454f45/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190620154339-431033348dd0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -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= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -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.42.0/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.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk= -gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= -gopkg.in/src-d/go-git.v4 v4.12.0/go.mod h1:zjlNnzc1Wjn43v3Mtii7RVxiReNP0fIu9npcXKzuNp4= -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= -gopkg.in/yaml.v2 v2.2.2/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= -xorm.io/builder v0.3.5/go.mod h1:ZFbByS/KxZI1FKRjL05PyJ4YrK2bcxlUaAxdum5aTR8= -xorm.io/core v0.6.3/go.mod h1:8kz/C6arVW/O9vk3PgCiMJO2hIAm1UcuOL3dSPyZ2qo= diff --git a/gitea/hook.go b/gitea/hook.go index 9149b49..59c3eaf 100644 --- a/gitea/hook.go +++ b/gitea/hook.go @@ -9,24 +9,29 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// Hook is equal to structs.Hook -type Hook = structs.Hook - -// HookList is equal to structs.HookList -type HookList = structs.HookList +// 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"` + Updated time.Time `json:"updated_at"` + Created time.Time `json:"created_at"` +} // ListOrgHooks list all the hooks of one organization -func (c *Client) ListOrgHooks(org string) (HookList, error) { +func (c *Client) ListOrgHooks(org string) ([]*Hook, error) { hooks := make([]*Hook, 0, 10) return hooks, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks", org), nil, nil, &hooks) } // ListRepoHooks list all the hooks of one repository -func (c *Client) ListRepoHooks(user, repo string) (HookList, error) { +func (c *Client) ListRepoHooks(user, repo string) ([]*Hook, error) { hooks := make([]*Hook, 0, 10) return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), nil, nil, &hooks) } @@ -43,8 +48,17 @@ 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 { + Type string `json:"type"` + Config map[string]string `json:"config"` + Events []string `json:"events"` + BranchFilter string `json:"branch_filter"` + Active bool `json:"active"` +} + // CreateOrgHook create one hook for an organization, with options -func (c *Client) CreateOrgHook(org string, opt structs.CreateHookOption) (*Hook, error) { +func (c *Client) CreateOrgHook(org string, opt CreateHookOption) (*Hook, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -54,7 +68,7 @@ func (c *Client) CreateOrgHook(org string, opt structs.CreateHookOption) (*Hook, } // CreateRepoHook create one hook for a repository, with options -func (c *Client) CreateRepoHook(user, repo string, opt structs.CreateHookOption) (*Hook, error) { +func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -63,8 +77,16 @@ func (c *Client) CreateRepoHook(user, repo string, opt structs.CreateHookOption) 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"` + BranchFilter string `json:"branch_filter"` + 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 structs.EditHookOption) error { +func (c *Client) EditOrgHook(org string, id int64, opt EditHookOption) error { body, err := json.Marshal(&opt) if err != nil { return err @@ -74,7 +96,7 @@ func (c *Client) EditOrgHook(org string, id int64, opt structs.EditHookOption) e } // EditRepoHook modify one hook of a repository, with hook id and options -func (c *Client) EditRepoHook(user, repo string, id int64, opt structs.EditHookOption) error { +func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) error { body, err := json.Marshal(&opt) if err != nil { return err diff --git a/gitea/issue.go b/gitea/issue.go index 20e84b5..35c1a1b 100644 --- a/gitea/issue.go +++ b/gitea/issue.go @@ -9,30 +9,59 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// PullRequestMeta is equal to structs.PullRequestMeta -type PullRequestMeta = structs.PullRequestMeta +// PullRequestMeta PR info if an issue is a PR +type PullRequestMeta struct { + HasMerged bool `json:"merged"` + Merged *time.Time `json:"merged_at"` +} -// Issue is equal to structs.Issue -type Issue = structs.Issue +// Issue represents an issue in a repository +type Issue struct { + ID int64 `json:"id"` + URL string `json:"url"` + Index int64 `json:"number"` + Poster *User `json:"user"` + OriginalAuthor string `json:"original_author"` + OriginalAuthorID int64 `json:"original_author_id"` + 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 + State StateType `json:"state"` + Comments int `json:"comments"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` + Closed *time.Time `json:"closed_at"` + Deadline *time.Time `json:"due_date"` + PullRequest *PullRequestMeta `json:"pull_request"` +} + +// ListIssueOption list issue options +type ListIssueOption struct { + Page int + State string +} // ListIssues returns all issues assigned the authenticated user -func (c *Client) ListIssues(opt structs.ListIssueOption) ([]*Issue, error) { +func (c *Client) ListIssues(opt 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 structs.ListIssueOption) ([]*Issue, error) { +func (c *Client) ListUserIssues(opt 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 structs.ListIssueOption) ([]*Issue, error) { +func (c *Client) ListRepoIssues(owner, repo string, opt 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) } @@ -43,8 +72,23 @@ 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 { + Title string `json:"title"` + Body string `json:"body"` + // username of assignee + Assignee string `json:"assignee"` + Assignees []string `json:"assignees"` + 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 structs.CreateIssueOption) (*Issue, error) { +func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -54,8 +98,19 @@ func (c *Client) CreateIssue(owner, repo string, opt structs.CreateIssueOption) 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"` + 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 structs.EditIssueOption) (*Issue, error) { +func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption) (*Issue, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/issue_comment.go b/gitea/issue_comment.go index ae8301a..119f7e5 100644 --- a/gitea/issue_comment.go +++ b/gitea/issue_comment.go @@ -8,12 +8,22 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// Comment is equal to structs.Comment -type Comment = structs.Comment +// 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"` + OriginalAuthor string `json:"original_author"` + OriginalAuthorID int64 `json:"original_author_id"` + Body string `json:"body"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` +} // ListIssueComments list comments on an issue. func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment, error) { @@ -27,8 +37,13 @@ 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 { + Body string `json:"body"` +} + // CreateIssueComment create comment on an issue. -func (c *Client) CreateIssueComment(owner, repo string, index int64, opt structs.CreateIssueCommentOption) (*Comment, error) { +func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateIssueCommentOption) (*Comment, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -37,8 +52,13 @@ func (c *Client) CreateIssueComment(owner, repo string, index int64, opt structs 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 { + Body string `json:"body"` +} + // EditIssueComment edits an issue comment. -func (c *Client) EditIssueComment(owner, repo string, commentID int64, opt structs.EditIssueCommentOption) (*Comment, error) { +func (c *Client) EditIssueComment(owner, repo string, commentID int64, opt EditIssueCommentOption) (*Comment, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/issue_label.go b/gitea/issue_label.go index cca0221..c865062 100644 --- a/gitea/issue_label.go +++ b/gitea/issue_label.go @@ -8,12 +8,17 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" ) -// Label is equal to structs.Label -type Label = structs.Label +// Label a label to an issue or a pr +type Label struct { + ID int64 `json:"id"` + Name string `json:"name"` + // example: 00aabb + Color string `json:"color"` + Description string `json:"description"` + URL string `json:"url"` +} // ListRepoLabels list labels of one repository func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) { @@ -28,8 +33,16 @@ 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 { + Name string `json:"name"` + // example: #00aabb + Color string `json:"color"` + Description string `json:"description"` +} + // CreateLabel create one label of repository -func (c *Client) CreateLabel(owner, repo string, opt structs.CreateLabelOption) (*Label, error) { +func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -39,8 +52,15 @@ func (c *Client) CreateLabel(owner, repo string, opt structs.CreateLabelOption) jsonHeader, bytes.NewReader(body), label) } +// EditLabelOption options for editing a label +type EditLabelOption struct { + Name *string `json:"name"` + Color *string `json:"color"` + Description *string `json:"description"` +} + // EditLabel modify one label with options -func (c *Client) EditLabel(owner, repo string, id int64, opt structs.EditLabelOption) (*Label, error) { +func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (*Label, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -62,8 +82,14 @@ func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, erro return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil, &labels) } +// IssueLabelsOption a collection of labels +type IssueLabelsOption struct { + // list of label IDs + Labels []int64 `json:"labels"` +} + // AddIssueLabels add one or more labels to one issue -func (c *Client) AddIssueLabels(owner, repo string, index int64, opt structs.IssueLabelsOption) ([]*Label, error) { +func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -73,7 +99,7 @@ func (c *Client) AddIssueLabels(owner, repo string, index int64, opt structs.Iss } // ReplaceIssueLabels replace old labels of issue with new labels -func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt structs.IssueLabelsOption) ([]*Label, error) { +func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/issue_milestone.go b/gitea/issue_milestone.go index d2317ac..f316e17 100644 --- a/gitea/issue_milestone.go +++ b/gitea/issue_milestone.go @@ -8,12 +8,32 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// Milestone is equal to structs.Milestone -type Milestone = structs.Milestone +// StateType issue state type +type StateType string + +const ( + // StateOpen pr is opend + StateOpen StateType = "open" + // StateClosed pr is closed + StateClosed StateType = "closed" + // StateAll is all + StateAll StateType = "all" +) + +// 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"` + Closed *time.Time `json:"closed_at"` + Deadline *time.Time `json:"due_on"` +} // ListRepoMilestones list all the milestones of one repository func (c *Client) ListRepoMilestones(owner, repo string) ([]*Milestone, error) { @@ -27,8 +47,15 @@ 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"` + Deadline *time.Time `json:"due_on"` +} + // CreateMilestone create one milestone with options -func (c *Client) CreateMilestone(owner, repo string, opt structs.CreateMilestoneOption) (*Milestone, error) { +func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) (*Milestone, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -37,8 +64,16 @@ func (c *Client) CreateMilestone(owner, repo string, opt structs.CreateMilestone 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 structs.EditMilestoneOption) (*Milestone, error) { +func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOption) (*Milestone, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/issue_tracked_time.go b/gitea/issue_tracked_time.go index 682a295..faec0a0 100644 --- a/gitea/issue_tracked_time.go +++ b/gitea/issue_tracked_time.go @@ -8,36 +8,45 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// TrackedTime is equal to structs.TrackedTime -type TrackedTime = structs.TrackedTime - -// TrackedTimes is equal to structs.TrackedTimes -type TrackedTimes = structs.TrackedTimes +// TrackedTime worked time for an issue / pr +type TrackedTime struct { + ID int64 `json:"id"` + Created time.Time `json:"created"` + // Time in seconds + Time int64 `json:"time"` + UserID int64 `json:"user_id"` + IssueID int64 `json:"issue_id"` +} // GetUserTrackedTimes list tracked times of a user -func (c *Client) GetUserTrackedTimes(owner, repo, user string) (TrackedTimes, error) { - times := make(TrackedTimes, 0, 10) +func (c *Client) GetUserTrackedTimes(owner, repo, user string) ([]*TrackedTime, error) { + times := make([]*TrackedTime, 0, 10) return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times/%s", owner, repo, user), nil, nil, ×) } // GetRepoTrackedTimes list tracked times of a repository -func (c *Client) GetRepoTrackedTimes(owner, repo string) (TrackedTimes, error) { - times := make(TrackedTimes, 0, 10) +func (c *Client) GetRepoTrackedTimes(owner, repo string) ([]*TrackedTime, error) { + times := make([]*TrackedTime, 0, 10) return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times", owner, repo), nil, nil, ×) } // GetMyTrackedTimes list tracked times of the current user -func (c *Client) GetMyTrackedTimes() (TrackedTimes, error) { - times := make(TrackedTimes, 0, 10) +func (c *Client) GetMyTrackedTimes() ([]*TrackedTime, error) { + times := make([]*TrackedTime, 0, 10) return times, c.getParsedResponse("GET", "/user/times", nil, nil, ×) } +// AddTimeOption options for adding time to an issue +type AddTimeOption struct { + // time in seconds + Time int64 `json:"time"` +} + // AddTime adds time to issue with the given index -func (c *Client) AddTime(owner, repo string, index int64, opt structs.AddTimeOption) (*TrackedTime, error) { +func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*TrackedTime, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -48,7 +57,7 @@ func (c *Client) AddTime(owner, repo string, index int64, opt structs.AddTimeOpt } // ListTrackedTimes get tracked times of one issue via issue id -func (c *Client) ListTrackedTimes(owner, repo string, index int64) (TrackedTimes, error) { - times := make(TrackedTimes, 0, 5) +func (c *Client) ListTrackedTimes(owner, repo string, index int64) ([]*TrackedTime, error) { + times := make([]*TrackedTime, 0, 5) return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil, ×) } diff --git a/gitea/miscellaneous.go b/gitea/miscellaneous.go index f1f893a..6251bca 100644 --- a/gitea/miscellaneous.go +++ b/gitea/miscellaneous.go @@ -4,10 +4,10 @@ package gitea -import "code.gitea.io/gitea/modules/structs" - // ServerVersion returns the version of the server func (c *Client) ServerVersion() (string, error) { - v := structs.ServerVersion{} + var v = struct { + Version string `json:"version"` + }{} return v.Version, c.getParsedResponse("GET", "/api/v1/version", nil, nil, &v) } diff --git a/gitea/org.go b/gitea/org.go index 2f94b9d..4b80361 100644 --- a/gitea/org.go +++ b/gitea/org.go @@ -9,12 +9,19 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" ) -// Organization is equal to structs.Organization -type Organization = structs.Organization +// 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 string `json:"visibility"` +} // ListMyOrgs list all of current user's organizations func (c *Client) ListMyOrgs() ([]*Organization, error) { @@ -34,8 +41,20 @@ 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 { + UserName string `json:"username"` + FullName string `json:"full_name"` + Description string `json:"description"` + Website string `json:"website"` + Location string `json:"location"` + // possible values are `public` (default), `limited` or `private` + // enum: public,limited,private + Visibility string `json:"visibility"` +} + // CreateOrg creates an organization -func (c *Client) CreateOrg(opt structs.CreateOrgOption) (*Organization, error) { +func (c *Client) CreateOrg(opt CreateOrgOption) (*Organization, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -44,8 +63,19 @@ func (c *Client) CreateOrg(opt structs.CreateOrgOption) (*Organization, error) { return org, c.getParsedResponse("POST", "/orgs", jsonHeader, bytes.NewReader(body), org) } +// 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"` + // possible values are `public`, `limited` or `private` + // enum: public,limited,private + Visibility string `json:"visibility"` +} + // EditOrg modify one organization via options -func (c *Client) EditOrg(orgname string, opt structs.EditOrgOption) error { +func (c *Client) EditOrg(orgname string, opt EditOrgOption) error { body, err := json.Marshal(&opt) if err != nil { return err diff --git a/gitea/org_member.go b/gitea/org_member.go index 100597d..992e794 100644 --- a/gitea/org_member.go +++ b/gitea/org_member.go @@ -8,12 +8,15 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" ) +// AddOrgMembershipOption add user to organization options +type AddOrgMembershipOption struct { + Role string `json:"role"` +} + // AddOrgMembership add some one to an organization's member -func (c *Client) AddOrgMembership(org, user string, opt structs.AddOrgMembershipOption) error { +func (c *Client) AddOrgMembership(org, user string, opt AddOrgMembershipOption) error { body, err := json.Marshal(&opt) if err != nil { return err diff --git a/gitea/org_team.go b/gitea/org_team.go index 1a10254..a8d4373 100644 --- a/gitea/org_team.go +++ b/gitea/org_team.go @@ -8,12 +8,19 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" ) -// Team is equal to structs.Team -type Team = structs.Team +// 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"` + // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] + Units []string `json:"units"` +} // ListOrgTeams lists all teams of an organization func (c *Client) ListOrgTeams(org string) ([]*Team, error) { @@ -33,8 +40,18 @@ func (c *Client) GetTeam(id int64) (*Team, error) { return t, c.getParsedResponse("GET", fmt.Sprintf("/teams/%d", id), nil, nil, t) } +// CreateTeamOption options for creating a team +type CreateTeamOption struct { + Name string `json:"name"` + Description string `json:"description"` + // enum: read,write,admin + Permission string `json:"permission"` + // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] + Units []string `json:"units"` +} + // CreateTeam creates a team for an organization -func (c *Client) CreateTeam(org string, opt structs.CreateTeamOption) (*Team, error) { +func (c *Client) CreateTeam(org string, opt CreateTeamOption) (*Team, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -43,8 +60,18 @@ func (c *Client) CreateTeam(org string, opt structs.CreateTeamOption) (*Team, er return t, c.getParsedResponse("POST", fmt.Sprintf("/orgs/%s/teams", org), jsonHeader, bytes.NewReader(body), t) } +// EditTeamOption options for editing a team +type EditTeamOption struct { + Name string `json:"name"` + Description string `json:"description"` + // enum: read,write,admin + Permission string `json:"permission"` + // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] + Units []string `json:"units"` +} + // EditTeam edits a team of an organization -func (c *Client) EditTeam(id int64, opt structs.EditTeamOption) error { +func (c *Client) EditTeam(id int64, opt EditTeamOption) error { body, err := json.Marshal(&opt) if err != nil { return err diff --git a/gitea/org_type.go b/gitea/org_type.go index 8dfb24f..930be18 100644 --- a/gitea/org_type.go +++ b/gitea/org_type.go @@ -4,10 +4,22 @@ package gitea -import "code.gitea.io/gitea/modules/structs" +// 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 +) // ExtractKeysFromMapString provides a slice of keys from map -func ExtractKeysFromMapString(in map[string]structs.VisibleType) (keys []string) { +func ExtractKeysFromMapString(in map[string]VisibleType) (keys []string) { for k := range in { keys = append(keys, k) } diff --git a/gitea/pull.go b/gitea/pull.go index 35794a9..0e03a05 100644 --- a/gitea/pull.go +++ b/gitea/pull.go @@ -8,15 +8,61 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// PullRequest is equal to structs.PullRequest -type PullRequest = structs.PullRequest +// 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"` +} + +// 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"` + 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"` + + Deadline *time.Time `json:"due_date"` + Created *time.Time `json:"created_at"` + Updated *time.Time `json:"updated_at"` + Closed *time.Time `json:"closed_at"` +} + +// ListPullRequestsOptions options for listing pull requests +type ListPullRequestsOptions struct { + Page int `json:"page"` + State string `json:"state"` +} // ListRepoPullRequests list PRs of one repository -func (c *Client) ListRepoPullRequests(owner, repo string, opt structs.ListPullRequestsOptions) ([]*PullRequest, error) { +func (c *Client) ListRepoPullRequests(owner, repo string, opt ListPullRequestsOptions) ([]*PullRequest, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -31,8 +77,21 @@ 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"` + Base string `json:"base"` + Title string `json:"title"` + Body string `json:"body"` + Assignee string `json:"assignee"` + Assignees []string `json:"assignees"` + Milestone int64 `json:"milestone"` + Labels []int64 `json:"labels"` + Deadline *time.Time `json:"due_date"` +} + // CreatePullRequest create pull request with options -func (c *Client) CreatePullRequest(owner, repo string, opt structs.CreatePullRequestOption) (*PullRequest, error) { +func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOption) (*PullRequest, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -42,8 +101,20 @@ func (c *Client) CreatePullRequest(owner, repo string, opt structs.CreatePullReq 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"` + 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 structs.EditPullRequestOption) (*PullRequest, error) { +func (c *Client) EditPullRequest(owner, repo string, index int64, opt EditPullRequestOption) (*PullRequest, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/release.go b/gitea/release.go index e7ef65b..20f63f6 100644 --- a/gitea/release.go +++ b/gitea/release.go @@ -8,12 +8,26 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// Release is equal to structs.Release -type Release = structs.Release +// 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"` + CreatedAt time.Time `json:"created_at"` + PublishedAt time.Time `json:"published_at"` + Publisher *User `json:"author"` + Attachments []*Attachment `json:"assets"` +} // ListReleases list releases of a repository func (c *Client) ListReleases(user, repo string) ([]*Release, error) { @@ -33,8 +47,18 @@ func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) { return r, err } +// CreateReleaseOption options when creating a release +type CreateReleaseOption 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"` +} + // CreateRelease create a release -func (c *Client) CreateRelease(user, repo string, form structs.CreateReleaseOption) (*Release, error) { +func (c *Client) CreateRelease(user, repo string, form CreateReleaseOption) (*Release, error) { body, err := json.Marshal(form) if err != nil { return nil, err @@ -46,8 +70,18 @@ func (c *Client) CreateRelease(user, repo string, form structs.CreateReleaseOpti 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 structs.EditReleaseOption) (*Release, error) { +func (c *Client) EditRelease(user, repo string, id int64, form EditReleaseOption) (*Release, error) { body, err := json.Marshal(form) if err != nil { return nil, err diff --git a/gitea/repo.go b/gitea/repo.go index 1a809c2..4556f17 100644 --- a/gitea/repo.go +++ b/gitea/repo.go @@ -8,15 +8,53 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// Repository is equal to structs.Repository -type Repository = structs.Repository +// Permission represents a set of permissions +type Permission struct { + Admin bool `json:"admin"` + Push bool `json:"push"` + Pull bool `json:"pull"` +} -// CreateRepoOption is equal to structs.CreateRepoOption -type CreateRepoOption = structs.CreateRepoOption +// 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"` + OriginalURL string `json:"original_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"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` + Permissions *Permission `json:"permissions,omitempty"` + HasIssues bool `json:"has_issues"` + HasWiki bool `json:"has_wiki"` + HasPullRequests bool `json:"has_pull_requests"` + IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"` + AllowMerge bool `json:"allow_merge_commits"` + AllowRebase bool `json:"allow_rebase"` + AllowRebaseMerge bool `json:"allow_rebase_explicit"` + AllowSquash bool `json:"allow_squash_merge"` + AvatarURL string `json:"avatar_url"` +} // ListMyRepos lists all repositories for the authenticated user that has access to. func (c *Client) ListMyRepos() ([]*Repository, error) { @@ -36,6 +74,27 @@ 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 +type CreateRepoOption struct { + // Name of the repository to create + // + Name string `json:"name"` + // Description of the repository to create + Description string `json:"description"` + // Whether the repository is private + Private bool `json:"private"` + // Issue Label set to use + IssueLabels string `json:"issue_labels"` + // 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) { body, err := json.Marshal(&opt) @@ -62,8 +121,42 @@ 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 +type EditRepoOption struct { + // name of the repository + Name *string `json:"name,omitempty"` + // a short description of the repository. + Description *string `json:"description,omitempty"` + // a URL with more information about the repository. + Website *string `json:"website,omitempty"` + // 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. + HasIssues *bool `json:"has_issues,omitempty"` + // either `true` to enable the wiki for this repository or `false` to disable it. + HasWiki *bool `json:"has_wiki,omitempty"` + // sets the default branch for this repository. + DefaultBranch *string `json:"default_branch,omitempty"` + // either `true` to allow pull requests, or `false` to prevent pull request. + HasPullRequests *bool `json:"has_pull_requests,omitempty"` + // either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. `has_pull_requests` must be `true`. + IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"` + // either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `has_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. `has_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. `has_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. `has_pull_requests` must be `true`. + AllowSquash *bool `json:"allow_squash_merge,omitempty"` + // set to `true` to archive this repository. + Archived *bool `json:"archived,omitempty"` +} + // EditRepo edit the properties of a repository -func (c *Client) EditRepo(owner, reponame string, opt structs.EditRepoOption) (*Repository, error) { +func (c *Client) EditRepo(owner, reponame string, opt EditRepoOption) (*Repository, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -78,12 +171,24 @@ func (c *Client) DeleteRepo(owner, repo string) error { return err } +// MigrateRepoOption options for migrating a repository from an external service +type MigrateRepoOption struct { + CloneAddr string `json:"clone_addr"` + AuthUsername string `json:"auth_username"` + AuthPassword string `json:"auth_password"` + UID int `json:"uid"` + RepoName string `json:"repo_name"` + 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 structs.MigrateRepoOption) (*Repository, error) { +func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/repo_branch.go b/gitea/repo_branch.go index bb3e162..2c7e811 100644 --- a/gitea/repo_branch.go +++ b/gitea/repo_branch.go @@ -6,12 +6,48 @@ package gitea import ( "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// Branch is equal to structs.Branch -type Branch = structs.Branch +// PayloadUser represents the author or committer of a commit +type PayloadUser struct { + // Full name of the commit author + Name string `json:"name"` + 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"` + 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"` +} + +// Branch represents a repository branch +type Branch struct { + Name string `json:"name"` + Commit *PayloadCommit `json:"commit"` +} // ListRepoBranches list all the branches of one repository func (c *Client) ListRepoBranches(user, repo string) ([]*Branch, error) { diff --git a/gitea/repo_collaborator.go b/gitea/repo_collaborator.go index 76d9396..bd61a22 100644 --- a/gitea/repo_collaborator.go +++ b/gitea/repo_collaborator.go @@ -8,8 +8,6 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" ) // ListCollaborators list a repository's collaborators @@ -35,8 +33,13 @@ 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 structs.AddCollaboratorOption) error { +func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollaboratorOption) error { body, err := json.Marshal(&opt) if err != nil { return err diff --git a/gitea/repo_commit.go b/gitea/repo_commit.go index d4c3993..c22c253 100644 --- a/gitea/repo_commit.go +++ b/gitea/repo_commit.go @@ -7,12 +7,44 @@ package gitea import ( "fmt" - - "code.gitea.io/gitea/modules/structs" ) -// Commit is equal to structs.Commit -type Commit = structs.Commit +// Identity for a person's identity like an author or committer +type Identity struct { + Name string `json:"name"` + Email string `json:"email"` +} + +// 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"` +} // GetSingleCommit returns a single commit func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) { diff --git a/gitea/repo_key.go b/gitea/repo_key.go index 563749e..29c885e 100644 --- a/gitea/repo_key.go +++ b/gitea/repo_key.go @@ -8,12 +8,21 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// DeployKey is equal to structs.DeployKey -type DeployKey = structs.DeployKey +// 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"` + Created time.Time `json:"created_at"` + ReadOnly bool `json:"read_only"` + Repository *Repository `json:"repository,omitempty"` +} // ListDeployKeys list all the deploy keys of one repository func (c *Client) ListDeployKeys(user, repo string) ([]*DeployKey, error) { @@ -28,7 +37,7 @@ func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error } // CreateDeployKey options when create one deploy key -func (c *Client) CreateDeployKey(user, repo string, opt structs.CreateKeyOption) (*DeployKey, error) { +func (c *Client) CreateDeployKey(user, repo string, opt CreateKeyOption) (*DeployKey, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/repo_refs.go b/gitea/repo_refs.go index f0f8369..b946a10 100644 --- a/gitea/repo_refs.go +++ b/gitea/repo_refs.go @@ -9,12 +9,21 @@ import ( "errors" "fmt" "strings" - - "code.gitea.io/gitea/modules/structs" ) -// Reference is equal to structs.Reference -type Reference = structs.Reference +// 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"` +} // GetRepoRef get one ref's information of one repository func (c *Client) GetRepoRef(user, repo, ref string) (*Reference, error) { diff --git a/gitea/repo_tag.go b/gitea/repo_tag.go index 10a9ed0..cc9c2e3 100644 --- a/gitea/repo_tag.go +++ b/gitea/repo_tag.go @@ -6,12 +6,16 @@ package gitea import ( "fmt" - - "code.gitea.io/gitea/modules/structs" ) -// Tag is equal to structs.Tag -type Tag = structs.Tag +// Tag represents a repository tag +type Tag struct { + Name string `json:"name"` + ID string `json:"id"` + Commit *CommitMeta `json:"commit"` + ZipballURL string `json:"zipball_url"` + TarballURL string `json:"tarball_url"` +} // ListRepoTags list all the branches of one repository func (c *Client) ListRepoTags(user, repo string) ([]*Tag, error) { diff --git a/gitea/repo_tree.go b/gitea/repo_tree.go index e68ffe3..842ab9b 100644 --- a/gitea/repo_tree.go +++ b/gitea/repo_tree.go @@ -6,14 +6,32 @@ 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) (*structs.GitTreeResponse, error) { - var trees structs.GitTreeResponse +func (c *Client) GetTrees(user, repo, ref string, recursive bool) (*GitTreeResponse, error) { + var trees GitTreeResponse var path = fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref) if recursive { path += "?recursive=1" diff --git a/gitea/repo_watch.go b/gitea/repo_watch.go index bf60f8c..1005f9f 100644 --- a/gitea/repo_watch.go +++ b/gitea/repo_watch.go @@ -7,12 +7,18 @@ package gitea import ( "fmt" "net/http" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// WatchInfo is equal to structs.WatchInfo -type WatchInfo = structs.WatchInfo +// 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"` +} // GetWatchedRepos list all the watched repos of user func (c *Client) GetWatchedRepos(user, pass string) ([]*Repository, error) { diff --git a/gitea/status.go b/gitea/status.go index c1035d5..ba9c18c 100644 --- a/gitea/status.go +++ b/gitea/status.go @@ -8,17 +8,51 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// Status is equal to structs.Status -type Status = structs.Status +// 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"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` +} + +// 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"` +} // CreateStatus creates a new Status for a given Commit // // POST /repos/:owner/:repo/statuses/:sha -func (c *Client) CreateStatus(owner, repo, sha string, opts structs.CreateStatusOption) (*Status, error) { +func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption) (*Status, error) { body, err := json.Marshal(&opts) if err != nil { return nil, err @@ -28,18 +62,34 @@ func (c *Client) CreateStatus(owner, repo, sha string, opts structs.CreateStatus jsonHeader, bytes.NewReader(body), status) } +// ListStatusesOption holds pagination information +type ListStatusesOption struct { + Page int +} + // ListStatuses returns all statuses for a given Commit // // GET /repos/:owner/:repo/commits/:ref/statuses -func (c *Client) ListStatuses(owner, repo, sha string, opts structs.ListStatusesOption) ([]*Status, error) { - statuses := make([]*structs.Status, 0, 10) +func (c *Client) ListStatuses(owner, repo, sha string, opts ListStatusesOption) ([]*Status, error) { + statuses := make([]*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) } +// 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"` +} + // GetCombinedStatus returns the CombinedStatus for a given Commit // // GET /repos/:owner/:repo/commits/:ref/status -func (c *Client) GetCombinedStatus(owner, repo, sha string) (*structs.CombinedStatus, error) { - status := &structs.CombinedStatus{} +func (c *Client) GetCombinedStatus(owner, repo, sha string) (*CombinedStatus, error) { + status := &CombinedStatus{} return status, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/status", owner, repo, sha), nil, nil, status) } diff --git a/gitea/user.go b/gitea/user.go index 6fc5d85..2433474 100644 --- a/gitea/user.go +++ b/gitea/user.go @@ -6,12 +6,27 @@ package gitea import ( "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// User is equal to structs.User -type User = structs.User +// User represents a user +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"` + 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"` + LastLogin time.Time `json:"last_login,omitempty"` + Created time.Time `json:"created,omitempty"` +} // GetUserInfo get user info by user's name func (c *Client) GetUserInfo(user string) (*User, error) { diff --git a/gitea/user_app.go b/gitea/user_app.go index 3e0fd20..773dcf3 100644 --- a/gitea/user_app.go +++ b/gitea/user_app.go @@ -11,8 +11,6 @@ import ( "encoding/json" "fmt" "net/http" - - "code.gitea.io/gitea/modules/structs" ) // BasicAuthEncode generate base64 of basic auth head @@ -20,8 +18,13 @@ func BasicAuthEncode(user, pass string) string { return base64.StdEncoding.EncodeToString([]byte(user + ":" + pass)) } -// AccessToken is equal to structs.AccessToken -type AccessToken = structs.AccessToken +// AccessToken represents an API access token. +type AccessToken struct { + ID int64 `json:"id"` + Name string `json:"name"` + Token string `json:"sha1"` + TokenLastEight string `json:"token_last_eight"` +} // ListAccessTokens lista all the access tokens of user func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) { @@ -30,8 +33,13 @@ 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 +type CreateAccessTokenOption struct { + Name string `json:"name"` +} + // CreateAccessToken create one access token with options -func (c *Client) CreateAccessToken(user, pass string, opt structs.CreateAccessTokenOption) (*AccessToken, error) { +func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOption) (*AccessToken, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/user_email.go b/gitea/user_email.go index 543bf8c..7823db1 100644 --- a/gitea/user_email.go +++ b/gitea/user_email.go @@ -7,12 +7,14 @@ package gitea import ( "bytes" "encoding/json" - - "code.gitea.io/gitea/modules/structs" ) -// Email is equal to structs.Email -type Email = structs.Email +// Email an email address belonging to a user +type Email struct { + Email string `json:"email"` + Verified bool `json:"verified"` + Primary bool `json:"primary"` +} // ListEmails all the email addresses of user func (c *Client) ListEmails() ([]*Email, error) { @@ -20,8 +22,14 @@ 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 structs.CreateEmailOption) ([]*Email, error) { +func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -30,8 +38,14 @@ func (c *Client) AddEmail(opt structs.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 structs.DeleteEmailOption) error { +func (c *Client) DeleteEmail(opt DeleteEmailOption) error { body, err := json.Marshal(&opt) if err != nil { return err diff --git a/gitea/user_gpgkey.go b/gitea/user_gpgkey.go index 474abcd..4830525 100644 --- a/gitea/user_gpgkey.go +++ b/gitea/user_gpgkey.go @@ -8,12 +8,30 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// GPGKey is equal to structs.GPGKey -type GPGKey = structs.GPGKey +// 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"` + Created time.Time `json:"created_at,omitempty"` + Expires time.Time `json:"expires_at,omitempty"` +} + +// GPGKeyEmail an email attached to a GPGKey +type GPGKeyEmail struct { + Email string `json:"email"` + Verified bool `json:"verified"` +} // ListGPGKeys list all the GPG keys of the user func (c *Client) ListGPGKeys(user string) ([]*GPGKey, error) { @@ -33,8 +51,15 @@ func (c *Client) GetGPGKey(keyID int64) (*GPGKey, error) { return key, c.getParsedResponse("GET", fmt.Sprintf("/user/gpg_keys/%d", keyID), nil, nil, &key) } +// CreateGPGKeyOption options create user GPG key +type CreateGPGKeyOption struct { + // An armored GPG key to add + // + ArmoredKey string `json:"armored_public_key"` +} + // CreateGPGKey create GPG key with options -func (c *Client) CreateGPGKey(opt structs.CreateGPGKeyOption) (*GPGKey, error) { +func (c *Client) CreateGPGKey(opt CreateGPGKeyOption) (*GPGKey, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/gitea/user_key.go b/gitea/user_key.go index 8d7d59a..34bbd1a 100644 --- a/gitea/user_key.go +++ b/gitea/user_key.go @@ -8,12 +8,21 @@ import ( "bytes" "encoding/json" "fmt" - - "code.gitea.io/gitea/modules/structs" + "time" ) -// PublicKey is equal to structs.PublicKey -type PublicKey = structs.PublicKey +// 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"` + Created time.Time `json:"created_at,omitempty"` + Owner *User `json:"user,omitempty"` + ReadOnly bool `json:"read_only,omitempty"` + KeyType string `json:"key_type,omitempty"` +} // ListPublicKeys list all the public keys of the user func (c *Client) ListPublicKeys(user string) ([]*PublicKey, error) { @@ -33,8 +42,18 @@ func (c *Client) GetPublicKey(keyID int64) (*PublicKey, error) { return key, c.getParsedResponse("GET", fmt.Sprintf("/user/keys/%d", keyID), nil, nil, &key) } +// CreateKeyOption options when creating a key +type CreateKeyOption struct { + // Title of the key to add + Title string `json:"title"` + // An armored SSH key to add + Key string `json:"key"` + // Describe if the key has only read access or read/write + ReadOnly bool `json:"read_only"` +} + // CreatePublicKey create public key with options -func (c *Client) CreatePublicKey(opt structs.CreateKeyOption) (*PublicKey, error) { +func (c *Client) CreatePublicKey(opt CreateKeyOption) (*PublicKey, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err