Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(VCS): matching author on email for VCS triggered issues (#1923)
h3n4ld0cea8b7b12f
diff --git a/plugin/vcs/gitlab/gitlab.go b/plugin/vcs/gitlab/gitlab.goindex a6d108ea9e..20f2a0c146 100644--- a/plugin/vcs/gitlab/gitlab.go+++ b/plugin/vcs/gitlab/gitlab.go@@ -76,7 +76,8 @@ type WebhookProject struct {// WebhookCommitAuthor is the API message for webhook commit author.type WebhookCommitAuthor struct {- Name string `json:"name"`+ Name string `json:"name"`+ Email string `json:"email"`}// WebhookCommit is the API message for webhook commit.diff --git a/plugin/vcs/vcs.go b/plugin/vcs/vcs.goindex abf3cbd3fc..025aaedae0 100644--- a/plugin/vcs/vcs.go+++ b/plugin/vcs/vcs.go@@ -42,13 +42,14 @@ type Commit struct {// FileCommit is the API message for a VCS file commit.type FileCommit struct {- ID string `json:"id"`- Title string `json:"title"`- Message string `json:"message"`- CreatedTs int64 `json:"createdTs"`- URL string `json:"url"`- AuthorName string `json:"authorName"`- Added string `json:"added"`+ ID string `json:"id"`+ Title string `json:"title"`+ Message string `json:"message"`+ CreatedTs int64 `json:"createdTs"`+ URL string `json:"url"`+ AuthorName string `json:"authorName"`+ AuthorEmail string `json:"authorEmail"`+ Added string `json:"added"`}// FileCommitCreate is the payload for committing a new file.diff --git a/server/webhook.go b/server/webhook.goindex d1fc8d0567..8cda512054 100644--- a/server/webhook.go+++ b/server/webhook.go@@ -104,13 +104,14 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {RepositoryFullPath: pushEvent.Project.FullPath,AuthorName: pushEvent.AuthorName,FileCommit: vcs.FileCommit{- ID: commit.ID,- Title: commit.Title,- Message: commit.Message,- CreatedTs: item.createdTime.Unix(),- URL: commit.URL,- AuthorName: commit.Author.Name,- Added: addedEscaped,+ ID: commit.ID,+ Title: commit.Title,+ Message: commit.Message,+ CreatedTs: item.createdTime.Unix(),+ URL: commit.URL,+ AuthorName: commit.Author.Name,+ AuthorEmail: commit.Author.Email,+ Added: addedEscaped,},}@@ -178,6 +179,19 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {}// Create schema update issue.+ creatorID := api.SystemBotID+ if commit.Author.Email != "" {+ committerPrinciple, err := s.store.GetPrincipalByEmail(ctx, commit.Author.Email)+ if err != nil {+ log.Error("failed to find the principal with committer email", zap.String("email", commit.Author.Email), zap.Error(err))+ }+ if committerPrinciple == nil {+ log.Debug("cannot find the principal with committer email, use system bot instead", zap.String("email", commit.Author.Email))+ } else {+ creatorID = committerPrinciple.ID+ }+ }+var createContext stringif repo.Project.TenantMode == api.TenantModeTenant {if !s.feature(api.FeatureMultiTenancy) {@@ -204,7 +218,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {AssigneeID: api.SystemBotID,CreateContext: createContext,}- issue, err := s.createIssue(ctx, issueCreate, api.SystemBotID)+ issue, err := s.createIssue(ctx, issueCreate, creatorID)if err != nil {errMsg := "Failed to create schema update issue"if issueType == api.IssueDatabaseDataUpdate {@@ -226,7 +240,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {}activityCreate := &api.ActivityCreate{- CreatorID: api.SystemBotID,+ CreatorID: creatorID,ContainerID: repo.ProjectID,Type: api.ActivityProjectRepositoryPush,Level: api.ActivityInfo,