diff --git a/go.mod b/go.mod index cbc40c24a35bd2ad6e4c087cfdd85026337c97c7..9d90f65045d8a2fe9ae067bc5d12e83e55abdd11 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module gitee.com/openeuler/ci-bot go 1.13 require ( - gitee.com/openeuler/go-gitee v0.0.0-20200115002700-1146e2471f99 + gitee.com/openeuler/go-gitee v0.0.0-20200306130508-ce7dbc91bc2b github.com/antihax/optional v1.0.0 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/protobuf v1.3.2 // indirect diff --git a/go.sum b/go.sum index b564f8e682c50c15c43a6e733c41eec851eb40a7..2d2929ae3e981e5dbdd0d2e34ef31f485d78cab8 100644 --- a/go.sum +++ b/go.sum @@ -2,12 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU= cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw= -gitee.com/openeuler/go-gitee v0.0.0-20191209072105-b1105b99c89c h1:i23w7TchKv3MgO1sUaqGTIPqn6yFs+qGrx/4/bABxmc= -gitee.com/openeuler/go-gitee v0.0.0-20191209072105-b1105b99c89c/go.mod h1:TQrS/LP/DFXLqM+lVrZd4nL2pbTrqiXABGT9PJepVTA= -gitee.com/openeuler/go-gitee v0.0.0-20191223095123-af9962c05d46 h1:BHOFDsWPs9Tv1S4AopiJSyNkgs+fdTFx3Kls6BCbxuE= -gitee.com/openeuler/go-gitee v0.0.0-20191223095123-af9962c05d46/go.mod h1:TQrS/LP/DFXLqM+lVrZd4nL2pbTrqiXABGT9PJepVTA= -gitee.com/openeuler/go-gitee v0.0.0-20200115002700-1146e2471f99 h1:am2TQ4rlTbJG590UzpiuOZYwNVxIgy09VHhIwX5fWBc= -gitee.com/openeuler/go-gitee v0.0.0-20200115002700-1146e2471f99/go.mod h1:TQrS/LP/DFXLqM+lVrZd4nL2pbTrqiXABGT9PJepVTA= +gitee.com/openeuler/go-gitee v0.0.0-20200306130508-ce7dbc91bc2b h1:ULJmyPxS+IYebY9VwDlhPIVeC+1FT/adRrvNO+2TS1I= +gitee.com/openeuler/go-gitee v0.0.0-20200306130508-ce7dbc91bc2b/go.mod h1:TQrS/LP/DFXLqM+lVrZd4nL2pbTrqiXABGT9PJepVTA= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= @@ -121,7 +117,6 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6 h1:pE8b58s1HRDMi8RDc79m0HISf9D4TzseP40cEA6IGfs= 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= diff --git a/pkg/cibot/database/database.go b/pkg/cibot/database/database.go index 29ca3666e279c1507bb3be9831e082f4581e0cbf..c7b2b04c07d5b4da59772179ba0a1863241beee4 100644 --- a/pkg/cibot/database/database.go +++ b/pkg/cibot/database/database.go @@ -56,7 +56,7 @@ func ConnectDataBase(config config.Config) (*gorm.DB, error) { func UpgradeDataBase(db *gorm.DB) error { // upgrades defines - upgrades := make([]func() error, 4) + upgrades := make([]func() error, 5) upgrades[0] = func() error { // table upgrades if err := db.Exec(UpgradesTableSQL).Error; err != nil { @@ -105,6 +105,13 @@ func UpgradeDataBase(db *gorm.DB) error { } return nil } + upgrades[4] = func() error { + // add commentable column for table repositories + if err := db.Exec(AddCommentableColumnRepositoriesTableSQL).Error; err != nil { + return err + } + return nil + } // Get UpgradeID var lastUpgrade = -1 diff --git a/pkg/cibot/database/repositories.go b/pkg/cibot/database/repositories.go index 080ece543ddbe6e69608e70e73023b255174b6b8..546cbbd982cd5872359f6053308acacdf149ea09 100644 --- a/pkg/cibot/database/repositories.go +++ b/pkg/cibot/database/repositories.go @@ -24,6 +24,10 @@ var RepositoriesTableSQL = fmt.Sprintf(`CREATE TABLE %s ( PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8`, RepositoriesTableName) +// AddCommentableColumnRepositoriesTableSQL adds a new column: commmentable +var AddCommentableColumnRepositoriesTableSQL = fmt.Sprintf(`ALTER TABLE %s + ADD commentable BOOLEAN NOT NULL DEFAULT 1`, RepositoriesTableName) + // Repositories defines type Repositories struct { gorm.Model @@ -31,6 +35,7 @@ type Repositories struct { Repo string Description string Type string + Commentable bool AdditionalInfo string `sql:"type:text"` } diff --git a/pkg/cibot/inithandler.go b/pkg/cibot/inithandler.go index fea2c5ca6d68b7c0c2c30cc7e0f94fed6d841c67..78cfd183a0736244f8dfeacaf5e2726ad0846382 100644 --- a/pkg/cibot/inithandler.go +++ b/pkg/cibot/inithandler.go @@ -53,6 +53,7 @@ type Repository struct { Name *string `yaml:"name"` Description *string `yaml:"description"` ProtectedBranches []string `yaml:"protected_branches"` + Commentable *bool `yaml:"commentable"` Type *string `yaml:"type"` Managers []string `yaml:"managers"` Developers []string `yaml:"developers"` @@ -60,6 +61,13 @@ type Repository struct { Reporters []string `yaml:"reporters"` } +// IsCommentable returns if contributors are able to comment +// to the repository. +// It will be true only if Commentable is explicitly sepecified as true +func (r Repository) IsCommentable() bool { + return (r.Commentable != nil && *r.Commentable) +} + // Serve func (handler *InitHandler) Serve() { // init waiting sha diff --git a/pkg/cibot/repohandler.go b/pkg/cibot/repohandler.go index 24268a81ae046d8f4eeae1f6ac4fdfed8f2d4466..319ec1b1079f29d034fddc663e5eaaca41c86130 100644 --- a/pkg/cibot/repohandler.go +++ b/pkg/cibot/repohandler.go @@ -194,8 +194,7 @@ func (handler *RepoHandler) watch() { glog.Infof("repository: %s is exist. no action.", *ps.Repositories[i].Name) } else { // add repository - err = handler.addRepositories(ps.Community, *ps.Repositories[i].Name, - *ps.Repositories[i].Description, *ps.Repositories[i].Type) + err = handler.addRepositories(ps.Community, ps.Repositories[i]) if err != nil { glog.Errorf("failed to add repositories: %v", err) result = false @@ -208,10 +207,10 @@ func (handler *RepoHandler) watch() { glog.Errorf("failed to handle branches: %v", err) result = false } - // handle repository type - err = handler.handleRepositoryTypes(ps.Community, ps.Repositories[i]) + // handle repository settings, currently type and can_comment are supported + err = handler.handleRepositorySetting(ps.Community, ps.Repositories[i]) if err != nil { - glog.Errorf("failed to handle repository types: %v", err) + glog.Errorf("failed to handle repository setting: %v", err) result = false } } @@ -260,16 +259,16 @@ func (handler *RepoHandler) getRepositoriesLength(owner string, repo string) (in } // addRepositories add repository -func (handler *RepoHandler) addRepositories(owner, repo, description, t string) error { +func (handler *RepoHandler) addRepositories(owner string, repo Repository) error { // add repository in gitee - err := handler.addRepositoriesinGitee(owner, repo, description, t) + err := handler.addRepositoriesinGitee(owner, repo) if err != nil { glog.Errorf("failed to add repositories: %v", err) return err } // add repository in database - err = handler.addRepositoriesinDB(owner, repo, description, t) + err = handler.addRepositoriesinDB(owner, repo) if err != nil { glog.Errorf("failed to add repositories: %v", err) return err @@ -278,13 +277,14 @@ func (handler *RepoHandler) addRepositories(owner, repo, description, t string) } // addRepositoriesinDB add repository in database -func (handler *RepoHandler) addRepositoriesinDB(owner, repo, description, t string) error { +func (handler *RepoHandler) addRepositoriesinDB(owner string, repo Repository) error { // add repository addrepo := database.Repositories{ Owner: owner, - Repo: repo, - Description: description, - Type: t, + Repo: *repo.Name, + Description: *repo.Description, + Type: *repo.Type, + Commentable: repo.IsCommentable(), } // create repository @@ -297,27 +297,24 @@ func (handler *RepoHandler) addRepositoriesinDB(owner, repo, description, t stri } // addRepositoriesinGitee add repository in giteee -func (handler *RepoHandler) addRepositoriesinGitee(owner, repo, description, t string) error { +func (handler *RepoHandler) addRepositoriesinGitee(owner string, repo Repository) error { // build create repository param repobody := gitee.RepositoryPostParam{} repobody.AccessToken = handler.Config.GiteeToken - repobody.Name = repo - repobody.Description = description + repobody.Name = *repo.Name + repobody.Description = *repo.Description repobody.HasIssues = true repobody.HasWiki = true // set `auto_init` as true to initialize `master` branch with README after repo creation repobody.AutoInit = true - if t == "private" { - repobody.Private = true - } else { - repobody.Private = false - } + repobody.CanComment = repo.IsCommentable() + repobody.Private = *repo.Type == "private" // invoke query repository - glog.Infof("begin to query repository: %s", repo) + glog.Infof("begin to query repository: %s", *repo.Name) localVarOptionals := &gitee.GetV5ReposOwnerRepoOpts{} localVarOptionals.AccessToken = optional.NewString(handler.Config.GiteeToken) - _, response, _ := handler.GiteeClient.RepositoriesApi.GetV5ReposOwnerRepo(handler.Context, owner, repo, localVarOptionals) + _, response, _ := handler.GiteeClient.RepositoriesApi.GetV5ReposOwnerRepo(handler.Context, owner, *repo.Name, localVarOptionals) if response.StatusCode == 404 { glog.Infof("repository is not exist: %s", repo) } else { @@ -479,25 +476,28 @@ func (handler *RepoHandler) addBranchProtections(community string, r Repository, return nil } -// handleRepositoryTypes handles that the repo is private or public -func (handler *RepoHandler) handleRepositoryTypes(community string, r Repository) error { +// handleRepositorySetting handles that the repo settings, including: +// 1. type is private or public +// 2. commentable is true or false +func (handler *RepoHandler) handleRepositorySetting(community string, r Repository) error { // get repos from DB var rs database.Repositories err := database.DBConnection.Model(&database.Repositories{}). Where("owner = ? and repo = ?", community, r.Name).First(&rs).Error if err != nil { - glog.Errorf("unable to get repositories files: %v", err) + glog.Errorf("unable to get repositories: %v", err) return err } - // the type is changed - if rs.Type != *r.Type { - // set value - isSetPrivate := false - if *r.Type == "private" { - isSetPrivate = true - } + typePrivateExpected := (*r.Type == "private") + // mark type as changed if the type from DB is NOT identical to yaml + typeChanged := (rs.Type != *r.Type) + + commentableExpected := r.IsCommentable() + // mark commentable as changed if the commentable from DB is NOT identical to yaml + commentableChanged := (rs.Commentable != commentableExpected) + if typeChanged || commentableChanged { // invoke query repository glog.Infof("begin to query repository: %s", *r.Name) localVarOptionals := &gitee.GetV5ReposOwnerRepoOpts{} @@ -508,35 +508,47 @@ func (handler *RepoHandler) handleRepositoryTypes(community string, r Repository glog.Infof("repository is not exist: %s", *r.Name) return nil } - if pj.Private == isSetPrivate { - glog.Infof("repository type is already: %s", *r.Type) - } else { + + // do we need to invoke the gitee patch api to change the setting of the repository + needInvokeRepoPatchAPI := false + // handle the change of type + if typeChanged { + // if the repo type from gitee is identical to yaml + if pj.Private == typePrivateExpected { + glog.Infof("repository type is already: %s", *r.Type) + } else { + needInvokeRepoPatchAPI = true + glog.Infof("going to change repo type via gitee API") + } + } + // handle the change of commentable + if commentableChanged { + // if the repo commentable from gitee is identical to yaml + if pj.CanComment == commentableExpected { + glog.Infof("repository commentable is already: %t", pj.CanComment) + } else { + needInvokeRepoPatchAPI = true + glog.Infof("going to change repo commentable via gitee API") + } + } + + // now to invoke gitee api to change the repo settings + if needInvokeRepoPatchAPI { // build patch repository param patchBody := gitee.RepoPatchParam{} patchBody.AccessToken = handler.Config.GiteeToken patchBody.Name = pj.Name patchBody.Description = pj.Description patchBody.Homepage = pj.Homepage - if pj.HasIssues { - patchBody.HasIssues = "true" - } else { - patchBody.HasIssues = "false" - } - if pj.HasWiki { - patchBody.HasWiki = "true" - } else { - patchBody.HasWiki = "false" - } - if isSetPrivate { - patchBody.Private = "true" - } else { - patchBody.Private = "false" - } + patchBody.HasIssues = strconv.FormatBool(pj.HasIssues) + patchBody.HasWiki = strconv.FormatBool(pj.HasWiki) + patchBody.Private = strconv.FormatBool(typePrivateExpected) + patchBody.CanComment = strconv.FormatBool(commentableExpected) // invoke set type _, _, err = handler.GiteeClient.RepositoriesApi.PatchV5ReposOwnerRepo(handler.Context, community, *r.Name, patchBody) if err != nil { - glog.Errorf("unable to set repository type: %v", err) + glog.Errorf("unable to set repository settings: %v", err) return err } } @@ -544,9 +556,12 @@ func (handler *RepoHandler) handleRepositoryTypes(community string, r Repository // define update repository updaterepo := &database.Repositories{} updaterepo.ID = rs.ID - err = database.DBConnection.Model(updaterepo).Update("Type", *r.Type).Error + err = database.DBConnection.Model(updaterepo). + Update("Type", *r.Type). + Update("Commentable", commentableExpected). + Error if err != nil { - glog.Errorf("unable to update type: %v", err) + glog.Errorf("unable to update repository settings: %v", err) } } diff --git a/vendor/gitee.com/openeuler/go-gitee/gitee/api_repositories.go b/vendor/gitee.com/openeuler/go-gitee/gitee/api_repositories.go index c58d4948d299bb6335ba1e3bd3ce22f525f6a8b3..6df47f65b0729b41dc47b175d58372470382eb52 100644 --- a/vendor/gitee.com/openeuler/go-gitee/gitee/api_repositories.go +++ b/vendor/gitee.com/openeuler/go-gitee/gitee/api_repositories.go @@ -4170,6 +4170,7 @@ RepositoriesApiService 创建企业仓库 * @param "Homepage" (optional.String) - 主页(eg: https://gitee.com) * @param "HasIssues" (optional.Bool) - 允许提Issue与否。默认: 允许(true) * @param "HasWiki" (optional.Bool) - 提供Wiki与否。默认: 提供(true) + * @param "CanComment" (optional.Bool) - 允许用户对仓库进行评论。默认: 允许(true) * @param "AutoInit" (optional.Bool) - 值为true时则会用README初始化仓库。默认: 不初始化(false) * @param "GitignoreTemplate" (optional.String) - Git Ingore模版 * @param "LicenseTemplate" (optional.String) - License模版 @@ -4187,6 +4188,7 @@ type PostV5EnterprisesEnterpriseReposOpts struct { Homepage optional.String HasIssues optional.Bool HasWiki optional.Bool + CanComment optional.Bool AutoInit optional.Bool GitignoreTemplate optional.String LicenseTemplate optional.String @@ -4246,6 +4248,9 @@ func (a *RepositoriesApiService) PostV5EnterprisesEnterpriseRepos(ctx context.Co if localVarOptionals != nil && localVarOptionals.HasWiki.IsSet() { localVarFormParams.Add("has_wiki", parameterToString(localVarOptionals.HasWiki.Value(), "")) } + if localVarOptionals != nil && localVarOptionals.CanComment.IsSet() { + localVarFormParams.Add("can_comment", parameterToString(localVarOptionals.CanComment.Value(), "")) + } if localVarOptionals != nil && localVarOptionals.AutoInit.IsSet() { localVarFormParams.Add("auto_init", parameterToString(localVarOptionals.AutoInit.Value(), "")) } @@ -5175,6 +5180,7 @@ RepositoriesApiService 创建一个仓库 * @param "Homepage" (optional.String) - 主页(eg: https://gitee.com) * @param "HasIssues" (optional.Bool) - 允许提Issue与否。默认: 允许(true) * @param "HasWiki" (optional.Bool) - 提供Wiki与否。默认: 提供(true) + * @param "CanComment" (optional.Bool) - 允许用户对仓库进行评论。默认: 允许(true) * @param "AutoInit" (optional.Bool) - 值为true时则会用README初始化仓库。默认: 不初始化(false) * @param "GitignoreTemplate" (optional.String) - Git Ingore模版 * @param "LicenseTemplate" (optional.String) - License模版 @@ -5189,6 +5195,7 @@ type PostV5UserReposOpts struct { Homepage optional.String HasIssues optional.Bool HasWiki optional.Bool + CanComment optional.Bool AutoInit optional.Bool GitignoreTemplate optional.String LicenseTemplate optional.String @@ -5244,6 +5251,9 @@ func (a *RepositoriesApiService) PostV5UserRepos(ctx context.Context, name strin if localVarOptionals != nil && localVarOptionals.HasWiki.IsSet() { localVarFormParams.Add("has_wiki", parameterToString(localVarOptionals.HasWiki.Value(), "")) } + if localVarOptionals != nil && localVarOptionals.CanComment.IsSet() { + localVarFormParams.Add("can_comment", parameterToString(localVarOptionals.CanComment.Value(), "")) + } if localVarOptionals != nil && localVarOptionals.AutoInit.IsSet() { localVarFormParams.Add("auto_init", parameterToString(localVarOptionals.AutoInit.Value(), "")) } diff --git a/vendor/gitee.com/openeuler/go-gitee/gitee/api_webhooks.go b/vendor/gitee.com/openeuler/go-gitee/gitee/api_webhooks.go index 7a99f8c2036e0513aeb1bd94160834c978dceff1..abccd5d2cc97c90c270a29f9489a52cf387637f4 100644 --- a/vendor/gitee.com/openeuler/go-gitee/gitee/api_webhooks.go +++ b/vendor/gitee.com/openeuler/go-gitee/gitee/api_webhooks.go @@ -29,14 +29,14 @@ var ( type WebhooksApiService service /* -WebhooksApiService 删除一个仓库WebHook -删除一个仓库WebHook - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param owner 仓库所属空间地址(企业、组织或个人的地址path) - * @param repo 仓库路径(path) - * @param id Webhook的ID - * @param optional nil or *DeleteV5ReposOwnerRepoHooksIdOpts - Optional Parameters: - * @param "AccessToken" (optional.String) - 用户授权码 + WebhooksApiService 删除一个仓库WebHook + 删除一个仓库WebHook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param owner 仓库所属空间地址(企业、组织或个人的地址path) + * @param repo 仓库路径(path) + * @param id Webhook的ID + * @param optional nil or *DeleteV5ReposOwnerRepoHooksIdOpts - Optional Parameters: + * @param "AccessToken" (optional.String) - 用户授权码 */ @@ -112,17 +112,17 @@ func (a *WebhooksApiService) DeleteV5ReposOwnerRepoHooksId(ctx context.Context, } /* -WebhooksApiService 列出仓库的WebHooks -列出仓库的WebHooks - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param owner 仓库所属空间地址(企业、组织或个人的地址path) - * @param repo 仓库路径(path) - * @param optional nil or *GetV5ReposOwnerRepoHooksOpts - Optional Parameters: - * @param "AccessToken" (optional.String) - 用户授权码 - * @param "Page" (optional.Int32) - 当前的页码 - * @param "PerPage" (optional.Int32) - 每页的数量,最大为 100 - -@return []Hook + WebhooksApiService 列出仓库的WebHooks + 列出仓库的WebHooks + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param owner 仓库所属空间地址(企业、组织或个人的地址path) + * @param repo 仓库路径(path) + * @param optional nil or *GetV5ReposOwnerRepoHooksOpts - Optional Parameters: + * @param "AccessToken" (optional.String) - 用户授权码 + * @param "Page" (optional.Int32) - 当前的页码 + * @param "PerPage" (optional.Int32) - 每页的数量,最大为 100 + + @return []Hook */ type GetV5ReposOwnerRepoHooksOpts struct { @@ -223,16 +223,16 @@ func (a *WebhooksApiService) GetV5ReposOwnerRepoHooks(ctx context.Context, owner } /* -WebhooksApiService 获取仓库单个WebHook -获取仓库单个WebHook - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param owner 仓库所属空间地址(企业、组织或个人的地址path) - * @param repo 仓库路径(path) - * @param id Webhook的ID - * @param optional nil or *GetV5ReposOwnerRepoHooksIdOpts - Optional Parameters: - * @param "AccessToken" (optional.String) - 用户授权码 - -@return Hook + WebhooksApiService 获取仓库单个WebHook + 获取仓库单个WebHook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param owner 仓库所属空间地址(企业、组织或个人的地址path) + * @param repo 仓库路径(path) + * @param id Webhook的ID + * @param optional nil or *GetV5ReposOwnerRepoHooksIdOpts - Optional Parameters: + * @param "AccessToken" (optional.String) - 用户授权码 + + @return Hook */ type GetV5ReposOwnerRepoHooksIdOpts struct { @@ -326,23 +326,23 @@ func (a *WebhooksApiService) GetV5ReposOwnerRepoHooksId(ctx context.Context, own } /* -WebhooksApiService 更新一个仓库WebHook -更新一个仓库WebHook - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param owner 仓库所属空间地址(企业、组织或个人的地址path) - * @param repo 仓库路径(path) - * @param id Webhook的ID - * @param url 远程HTTP URL - * @param optional nil or *PatchV5ReposOwnerRepoHooksIdOpts - Optional Parameters: - * @param "AccessToken" (optional.String) - 用户授权码 - * @param "Password" (optional.String) - 请求URL时会带上该密码,防止URL被恶意请求 - * @param "PushEvents" (optional.Bool) - Push代码到仓库 - * @param "TagPushEvents" (optional.Bool) - 提交Tag到仓库 - * @param "IssuesEvents" (optional.Bool) - 创建/关闭Issue - * @param "NoteEvents" (optional.Bool) - 评论了Issue/代码等等 - * @param "MergeRequestsEvents" (optional.Bool) - 合并请求和合并后 - -@return Hook + WebhooksApiService 更新一个仓库WebHook + 更新一个仓库WebHook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param owner 仓库所属空间地址(企业、组织或个人的地址path) + * @param repo 仓库路径(path) + * @param id Webhook的ID + * @param url 远程HTTP URL + * @param optional nil or *PatchV5ReposOwnerRepoHooksIdOpts - Optional Parameters: + * @param "AccessToken" (optional.String) - 用户授权码 + * @param "Password" (optional.String) - 请求URL时会带上该密码,防止URL被恶意请求 + * @param "PushEvents" (optional.Bool) - Push代码到仓库 + * @param "TagPushEvents" (optional.Bool) - 提交Tag到仓库 + * @param "IssuesEvents" (optional.Bool) - 创建/关闭Issue + * @param "NoteEvents" (optional.Bool) - 评论了Issue/代码等等 + * @param "MergeRequestsEvents" (optional.Bool) - 合并请求和合并后 + + @return Hook */ type PatchV5ReposOwnerRepoHooksIdOpts struct { @@ -461,22 +461,22 @@ func (a *WebhooksApiService) PatchV5ReposOwnerRepoHooksId(ctx context.Context, o } /* -WebhooksApiService 创建一个仓库WebHook -创建一个仓库WebHook - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param owner 仓库所属空间地址(企业、组织或个人的地址path) - * @param repo 仓库路径(path) - * @param url 远程HTTP URL - * @param optional nil or *PostV5ReposOwnerRepoHooksOpts - Optional Parameters: - * @param "AccessToken" (optional.String) - 用户授权码 - * @param "Password" (optional.String) - 请求URL时会带上该密码,防止URL被恶意请求 - * @param "PushEvents" (optional.Bool) - Push代码到仓库 - * @param "TagPushEvents" (optional.Bool) - 提交Tag到仓库 - * @param "IssuesEvents" (optional.Bool) - 创建/关闭Issue - * @param "NoteEvents" (optional.Bool) - 评论了Issue/代码等等 - * @param "MergeRequestsEvents" (optional.Bool) - 合并请求和合并后 - -@return Hook + WebhooksApiService 创建一个仓库WebHook + 创建一个仓库WebHook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param owner 仓库所属空间地址(企业、组织或个人的地址path) + * @param repo 仓库路径(path) + * @param url 远程HTTP URL + * @param optional nil or *PostV5ReposOwnerRepoHooksOpts - Optional Parameters: + * @param "AccessToken" (optional.String) - 用户授权码 + * @param "Password" (optional.String) - 请求URL时会带上该密码,防止URL被恶意请求 + * @param "PushEvents" (optional.Bool) - Push代码到仓库 + * @param "TagPushEvents" (optional.Bool) - 提交Tag到仓库 + * @param "IssuesEvents" (optional.Bool) - 创建/关闭Issue + * @param "NoteEvents" (optional.Bool) - 评论了Issue/代码等等 + * @param "MergeRequestsEvents" (optional.Bool) - 合并请求和合并后 + + @return Hook */ type PostV5ReposOwnerRepoHooksOpts struct { @@ -594,14 +594,14 @@ func (a *WebhooksApiService) PostV5ReposOwnerRepoHooks(ctx context.Context, owne } /* -WebhooksApiService 测试WebHook是否发送成功 -测试WebHook是否发送成功 - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param owner 仓库所属空间地址(企业、组织或个人的地址path) - * @param repo 仓库路径(path) - * @param id Webhook的ID - * @param optional nil or *PostV5ReposOwnerRepoHooksIdTestsOpts - Optional Parameters: - * @param "AccessToken" (optional.String) - 用户授权码 + WebhooksApiService 测试WebHook是否发送成功 + 测试WebHook是否发送成功 + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param owner 仓库所属空间地址(企业、组织或个人的地址path) + * @param repo 仓库路径(path) + * @param id Webhook的ID + * @param optional nil or *PostV5ReposOwnerRepoHooksIdTestsOpts - Optional Parameters: + * @param "AccessToken" (optional.String) - 用户授权码 */ diff --git a/vendor/gitee.com/openeuler/go-gitee/gitee/hook_event_models.go b/vendor/gitee.com/openeuler/go-gitee/gitee/hook_event_models.go new file mode 100644 index 0000000000000000000000000000000000000000..c0cd6509e8873eee9ebc264f5ece6f44033112d4 --- /dev/null +++ b/vendor/gitee.com/openeuler/go-gitee/gitee/hook_event_models.go @@ -0,0 +1,41 @@ +package gitee + +type ProjectHook struct { + Id int32 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Path string `json:"path,omitempty"` + FullName string `json:"full_name,omitempty"` + Owner *UserBasic `json:"owner,omitempty"` + Private bool `json:"private,omitempty"` + HtmlUrl string `json:"html_url,omitempty"` + Url string `json:"url,omitempty"` + Description string `json:"description,omitempty"` + Fork bool `json:"fork,omitempty"` + PushedAt string `json:"pushed_at,omitempty"` + CreatedAt string `json:"created_at,omitempty"` + UpdatedAt string `json:"updated_at,omitempty"` + SshUrl string `json:"ssh_url,omitempty"` + GitUrl string `json:"git_url,omitempty"` + CloneUrl string `json:"clone_url,omitempty"` + SvnUrl string `json:"svn_url,omitempty"` + GitHttpUrl string `json:"git_http_url,omitempty"` + GitSshUrl string `json:"git_ssh_url,omitempty"` + GitSvnUrl string `json:"git_svn_url,omitempty"` + Homepage string `json:"homepage,omitempty"` + StargazersCount int32 `json:"stargazers_count,omitempty"` + WatchersCount int32 `json:"watchers_count,omitempty"` + ForksCount int32 `json:"forks_count,omitempty"` + Language string `json:"language,omitempty"` + + HasIssues bool `json:"has_issues,omitempty"` + HasWiki bool `json:"has_wiki,omitempty"` + HasPage bool `json:"has_pages,omitempty"` + License string `json:"license,omitempty"` + + OpenIssuesCount int32 `json:"open_issues_count,omitempty"` + DefaultBranch string `json:"default_branch,omitempty"` + Namespace string `json:"namespace,omitempty"` + + NameWithNamespace string `json:"name_with_namespace,omitempty"` + PathWithNamespace string `json:"path_with_namespace,omitempty"` +} diff --git a/vendor/gitee.com/openeuler/go-gitee/gitee/hook_event_types.go b/vendor/gitee.com/openeuler/go-gitee/gitee/hook_event_types.go index 3f2068d5e0b8fef483263b3be865430a1d1e6466..7d3e43e3071d36d4b8e3dd005962d8fcb3eb7578 100644 --- a/vendor/gitee.com/openeuler/go-gitee/gitee/hook_event_types.go +++ b/vendor/gitee.com/openeuler/go-gitee/gitee/hook_event_types.go @@ -3,8 +3,8 @@ package gitee type NoteEvent struct { Action *string `json:"action,omitempty"` Comment *Note `json:"comment,omitempty"` - Repository *Project `json:"repository,omitempty"` - Project *Project `json:"project,omitempty"` + Repository *ProjectHook `json:"repository,omitempty"` + Project *ProjectHook `json:"project,omitempty"` Author *User `json:"author,omitempty"` Sender *User `json:"sender,omitempty"` URL *string `json:"url,omitempty"` @@ -32,8 +32,8 @@ type PushEvent struct { Compare *string `json:"compare,omitempty"` Commits []Commit `json:"commits,omitempty"` HeadCommit *Commit `json:"head_commit,omitempty"` - Repository *Project `json:"repository,omitempty"` - Project *Project `json:"project,omitempty"` + Repository *ProjectHook `json:"repository,omitempty"` + Project *ProjectHook `json:"project,omitempty"` UserID int64 `json:"user_id,omitempty"` UserName *string `json:"user_name,omitempty"` User *User `json:"user,omitempty"` @@ -47,8 +47,8 @@ type PushEvent struct { type IssueEvent struct { Action *string `json:"action,omitempty"` Issue *Issue `json:"issue,omitempty"` - Repository *Project `json:"repository,omitempty"` - Project *Project `json:"project,omitempty"` + Repository *ProjectHook `json:"repository,omitempty"` + Project *ProjectHook `json:"project,omitempty"` Sender *User `json:"sender,omitempty"` TargetUser *User `json:"target_user,omitempty"` User *User `json:"user,omitempty"` @@ -66,8 +66,8 @@ type IssueEvent struct { } type RepoInfo struct { - Project *Project `json:"project,omitempty"` - Repository *Project `json:"repository,omitempty"` + Project *ProjectHook `json:"project,omitempty"` + Repository *ProjectHook `json:"repository,omitempty"` } type PullRequestEvent struct { @@ -85,8 +85,8 @@ type PullRequestEvent struct { SourceRepo *RepoInfo `json:"source_repo,omitempty"` TargetBranch *string `json:"target_branch,omitempty"` TargetRepo *RepoInfo `json:"target_repo,omitempty"` - Project *Project `json:"project,omitempty"` - Repository *Project `json:"repository,omitempty"` + Project *ProjectHook `json:"project,omitempty"` + Repository *ProjectHook `json:"repository,omitempty"` Author *User `json:"author,omitempty"` UpdatedBy *User `json:"updated_by,omitempty"` Sender *User `json:"sender,omitempty"` diff --git a/vendor/gitee.com/openeuler/go-gitee/gitee/model_project.go b/vendor/gitee.com/openeuler/go-gitee/gitee/model_project.go index 03bccfbbbcb5e550ef3b557b5c0f477b5a8918cd..9a93b380e16957565debc4329e8cd5b5a57a26d8 100644 --- a/vendor/gitee.com/openeuler/go-gitee/gitee/model_project.go +++ b/vendor/gitee.com/openeuler/go-gitee/gitee/model_project.go @@ -15,7 +15,7 @@ type Project struct { FullName string `json:"full_name,omitempty"` HumanName string `json:"human_name,omitempty"` Url string `json:"url,omitempty"` - Namespace string `json:"namespace,omitempty"` + Namespace *Namespace `json:"namespace,omitempty"` Path string `json:"path,omitempty"` Name string `json:"name,omitempty"` Owner *UserBasic `json:"owner,omitempty"` @@ -54,12 +54,13 @@ type Project struct { OpenIssuesCount int32 `json:"open_issues_count,omitempty"` HasIssues bool `json:"has_issues,omitempty"` HasWiki bool `json:"has_wiki,omitempty"` + CanComment bool `json:"can_comment,omitempty"` PullRequestsEnabled bool `json:"pull_requests_enabled,omitempty"` HasPage bool `json:"has_page,omitempty"` License string `json:"license,omitempty"` Outsourced bool `json:"outsourced,omitempty"` ProjectCreator string `json:"project_creator,omitempty"` - Members string `json:"members,omitempty"` + Members []string `json:"members,omitempty"` PushedAt string `json:"pushed_at,omitempty"` CreatedAt string `json:"created_at,omitempty"` UpdatedAt string `json:"updated_at,omitempty"` diff --git a/vendor/gitee.com/openeuler/go-gitee/gitee/model_repo_patch_param.go b/vendor/gitee.com/openeuler/go-gitee/gitee/model_repo_patch_param.go index 47df6ae1695239aab8da5dcbe9227fd3e0a0ed23..ff57762f62103eae0615c9fd31f9a626f9a2fab1 100644 --- a/vendor/gitee.com/openeuler/go-gitee/gitee/model_repo_patch_param.go +++ b/vendor/gitee.com/openeuler/go-gitee/gitee/model_repo_patch_param.go @@ -23,8 +23,12 @@ type RepoPatchParam struct { HasIssues string `json:"has_issues,omitempty"` // 提供Wiki与否。默认: 提供(true) HasWiki string `json:"has_wiki,omitempty"` + // 允许用户对仓库进行评论 + CanComment string `json:"can_comment,omitempty"` // 仓库公开或私有。 Private string `json:"private,omitempty"` + // 更新仓库路径 + Path string `json:"path,omitempty"` // 更新默认分支 DefaultBranch string `json:"default_branch,omitempty"` } diff --git a/vendor/gitee.com/openeuler/go-gitee/gitee/model_repository_post_param.go b/vendor/gitee.com/openeuler/go-gitee/gitee/model_repository_post_param.go index 716ab771b245c6f71b9a67657369afc4bc48a5cc..33821e457eb27f0152e43657fb7959f81c77b701 100644 --- a/vendor/gitee.com/openeuler/go-gitee/gitee/model_repository_post_param.go +++ b/vendor/gitee.com/openeuler/go-gitee/gitee/model_repository_post_param.go @@ -23,6 +23,8 @@ type RepositoryPostParam struct { HasIssues bool `json:"has_issues,omitempty"` // 提供Wiki与否。默认: 提供(true) HasWiki bool `json:"has_wiki,omitempty"` + // 允许用户对仓库进行评论。默认: 允许(true) + CanComment bool `json:"can_comment,omitempty"` // 仓库开源类型。0(私有), 1(外部开源), 2(内部开源),注:与private互斥,以public为主。 Public int32 `json:"public,omitempty"` // 仓库公开或私有。默认: 公开(false),注:与public互斥,以public为主。 diff --git a/vendor/gitee.com/openeuler/go-gitee/gitee/model_tree.go b/vendor/gitee.com/openeuler/go-gitee/gitee/model_tree.go index 027a92ec220074a66499b0a7ef91ecc02ec15a3c..236661d508bd4c6e99e6d1b645a4c6dee33043e9 100644 --- a/vendor/gitee.com/openeuler/go-gitee/gitee/model_tree.go +++ b/vendor/gitee.com/openeuler/go-gitee/gitee/model_tree.go @@ -11,8 +11,8 @@ package gitee // 获取目录Tree type Tree struct { - Sha string `json:"sha,omitempty"` - Url string `json:"url,omitempty"` - Tree string `json:"tree,omitempty"` - Truncated string `json:"truncated,omitempty"` + Sha string `json:"sha,omitempty"` + Url string `json:"url,omitempty"` + Tree []TreeBasic `json:"tree,omitempty"` + Truncated string `json:"truncated,omitempty"` } diff --git a/vendor/gitee.com/openeuler/go-gitee/gitee/model_tree_basic.go b/vendor/gitee.com/openeuler/go-gitee/gitee/model_tree_basic.go new file mode 100644 index 0000000000000000000000000000000000000000..aaa02d4ffd4f6e73442f047a18821beb21285cd6 --- /dev/null +++ b/vendor/gitee.com/openeuler/go-gitee/gitee/model_tree_basic.go @@ -0,0 +1,19 @@ +/* + * 码云 Open API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 5.3.2 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package gitee + +type TreeBasic struct { + Path string `json:"path,omitempty"` + Mode string `json:"mode,omitempty"` + Type_ string `json:"type,omitempty"` + Sha string `json:"sha,omitempty"` + Size int32 `json:"size,omitempty"` + Url string `json:"url,omitempty"` +} diff --git a/vendor/modules.txt b/vendor/modules.txt index b566291c3bf9502caa8cdadb87d7ab93fc0f183d..ec16def9301018cb0efab55f090e558c94fa6a16 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# gitee.com/openeuler/go-gitee v0.0.0-20200115002700-1146e2471f99 +# gitee.com/openeuler/go-gitee v0.0.0-20200306130508-ce7dbc91bc2b gitee.com/openeuler/go-gitee/gitee # github.com/antihax/optional v1.0.0 github.com/antihax/optional