Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: github pr comment (#11460)
Danny Xu9c5a776139ed
diff --git a/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yamlindex 7991f2b26f..929f17aaac 100644--- a/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml+++ b/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml@@ -3,7 +3,7 @@- status: WARNcode: 112title: schema.backward-compatibility- content: Drop table TEST_DB.dbo.mytable may cause incompatibility with the existing data and code+ content: Drop table TEST_DB.dbo.MyTable may cause incompatibility with the existing data and codeline: 1details: ""- statement: |-diff --git a/backend/plugin/vcs/azure/azure.go b/backend/plugin/vcs/azure/azure.goindex 5ad51fefc8..bc30cab31f 100644--- a/backend/plugin/vcs/azure/azure.go+++ b/backend/plugin/vcs/azure/azure.go@@ -368,6 +368,11 @@ func (p *Provider) ListPullRequestFile(ctx context.Context, repositoryID, lastMereturn files, nil}+// CreatePullRequestComment creates a pull request comment.+func (*Provider) CreatePullRequestComment(_ context.Context, _, _, _ string) error {+ return nil+}+// CreateWebhook creates a webhook in the organization, and returns the webhook ID which can be used in PatchWebhook.// API Version 7.0 do not specify the OAuth scope for creating webhook explicitly, but it works.//diff --git a/backend/plugin/vcs/bitbucket/bitbucket.go b/backend/plugin/vcs/bitbucket/bitbucket.goindex 5ba4bad88b..63097b9ce2 100644--- a/backend/plugin/vcs/bitbucket/bitbucket.go+++ b/backend/plugin/vcs/bitbucket/bitbucket.go@@ -310,6 +310,11 @@ func (p *Provider) ListPullRequestFile(ctx context.Context, repositoryID, pullRereturn files, nil}+// CreatePullRequestComment creates a pull request comment.+func (*Provider) CreatePullRequestComment(_ context.Context, _, _, _ string) error {+ return nil+}+// Link is the API message for link.type Link struct {Href string `json:"href"`diff --git a/backend/plugin/vcs/github/github.go b/backend/plugin/vcs/github/github.goindex 44760596f1..0ca923c886 100644--- a/backend/plugin/vcs/github/github.go+++ b/backend/plugin/vcs/github/github.go@@ -333,10 +333,41 @@ func (p *Provider) listPaginatedPullRequestFile(ctx context.Context, repositoryIreturn prFiles, nil}-// BranchCreate is the API message to create the branch.-type BranchCreate struct {- Ref string `json:"ref"`- SHA string `json:"sha"`+type Comment struct {+ Body string `json:"body"`+}++// CreatePullRequestComment creates a comment on the pull request.+//+// Issue comment makes comment on the pull request (Yes, you read it right).+// Pull request comment makes a pull request comment on the line.+// Pull request review makes a pull request review such as approval.+// Docs: https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#create-an-issue-comment+func (p *Provider) CreatePullRequestComment(ctx context.Context, repositoryID, pullRequestID, comment string) error {+ commentMessage := Comment{Body: comment}+ commentCreatePayload, err := json.Marshal(commentMessage)+ if err != nil {+ return errors.Wrap(err, "failed to marshal request body for creating pull request comment")+ }+ url := fmt.Sprintf("%s/repos/%s/issues/%s/comments", p.APIURL(p.instanceURL), repositoryID, pullRequestID)+ code, body, err := internal.Post(ctx, url, p.getAuthorization(), commentCreatePayload)+ if err != nil {+ return errors.Wrapf(err, "POST %s", url)+ }++ if code == http.StatusNotFound {+ return common.Errorf(common.NotFound, "failed to create pull request comment through URL %s", url)+ }++ // GitHub returns 201 HTTP status codes upon successful issue comment creation,+ if code != http.StatusCreated {+ return errors.Errorf("failed to create pull request comment through URL %s, status code: %d, body: %s",+ url,+ code,+ body,+ )+ }+ return nil}// Branch is the API message for GitHub branch.diff --git a/backend/plugin/vcs/gitlab/gitlab.go b/backend/plugin/vcs/gitlab/gitlab.goindex 30570b0e24..9bc1092626 100644--- a/backend/plugin/vcs/gitlab/gitlab.go+++ b/backend/plugin/vcs/gitlab/gitlab.go@@ -293,6 +293,11 @@ func (p *Provider) ListPullRequestFile(ctx context.Context, repositoryID, pullRereturn res, nil}+// CreatePullRequestComment creates a pull request comment.+func (*Provider) CreatePullRequestComment(_ context.Context, _, _, _ string) error {+ return nil+}+// Branch is the API message for GitLab branch.type Branch struct {Name string `json:"name"`diff --git a/backend/plugin/vcs/vcs.go b/backend/plugin/vcs/vcs.goindex be29e9051c..d8aaceeab8 100644--- a/backend/plugin/vcs/vcs.go+++ b/backend/plugin/vcs/vcs.go@@ -97,6 +97,9 @@ type Provider interface {// CreatePullRequest creates the pull request in the repository.ListPullRequestFile(ctx context.Context, repositoryID, pullRequestID string) ([]*PullRequestFile, error)+ // CreatePullRequestComment creates a pull request comment.+ CreatePullRequestComment(ctx context.Context, repositoryID, pullRequestID, comment string) error+// Creates a webhook. Returns the created webhook ID on success.CreateWebhook(ctx context.Context, repositoryID string, payload []byte) (string, error)diff --git a/backend/tests/fake/github.go b/backend/tests/fake/github.goindex a499a06b8c..44dd755be5 100644--- a/backend/tests/fake/github.go+++ b/backend/tests/fake/github.go@@ -69,7 +69,6 @@ func NewGitHub(port int) VCSProvider {g.GET("/repos/:owner/:repo/contents/:filePath", gh.readRepositoryFile)g.PUT("/repos/:owner/:repo/contents/:filePath", gh.createRepositoryFile)g.GET("/repos/:owner/:repo/git/ref/heads/:branchName", gh.getRepositoryBranch)- g.POST("/repos/:owner/:repo/git/refs", gh.createRepositoryBranch)g.GET("/repos/:owner/:repo/pulls/:prID/files", gh.listPullRequestFile)g.GET("/repos/:owner/:repo/compare/:baseHead", gh.compareCommits)return gh@@ -192,36 +191,6 @@ func (gh *GitHub) getRepositoryBranch(c echo.Context) error {return c.String(http.StatusOK, string(buf))}-func (gh *GitHub) createRepositoryBranch(c echo.Context) error {- r, err := gh.validRepository(c)- if err != nil {- return err- }-- body, err := io.ReadAll(c.Request().Body)- if err != nil {- return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to read request body for creating repository branch: %v", err))- }-- var branchCreate github.BranchCreate- if err = json.Unmarshal(body, &branchCreate); err != nil {- return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to unmarshal request body for creating repository branch: %v", err))- }-- if _, ok := r.refs[branchCreate.Ref]; ok {- return c.String(http.StatusBadRequest, fmt.Sprintf("the branch already exists: %v", branchCreate.Ref))- }-- r.refs[branchCreate.Ref] = &github.Branch{- Ref: branchCreate.Ref,- Object: github.ReferenceObject{- SHA: branchCreate.SHA,- },- }-- return c.String(http.StatusOK, "")-}-func (gh *GitHub) listPullRequestFile(c echo.Context) error {r, err := gh.validRepository(c)if err != nil {