This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a commit to branch dev-1
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/dev-1 by this push:
     new 6279bce57 feat(webhook): update deployment commit id
6279bce57 is described below

commit 6279bce57bebc3daca7c87bdf3cc08ec7f913ef3
Author: d4x1 <[email protected]>
AuthorDate: Fri May 17 11:05:45 2024 +0800

    feat(webhook): update deployment commit id
---
 backend/plugins/webhook/api/deployments.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/backend/plugins/webhook/api/deployments.go 
b/backend/plugins/webhook/api/deployments.go
index 47ff8e9b9..f49591bb3 100644
--- a/backend/plugins/webhook/api/deployments.go
+++ b/backend/plugins/webhook/api/deployments.go
@@ -69,9 +69,9 @@ type DeploymentCommit struct {
        CommitMsg    string `mapstructure:"commit_msg"`
 }
 
-func generateDeploymentCommitId(connectionId uint64, repoUrl string, commitSha 
string) string {
+func GenerateDeploymentCommitId(connectionId uint64, pipelineId string, 
repoUrl string, commitSha string) string {
        urlHash16 := fmt.Sprintf("%x", md5.Sum([]byte(repoUrl)))[:16]
-       return fmt.Sprintf("%s:%d:%s:%s", "webhook", connectionId, urlHash16, 
commitSha)
+       return fmt.Sprintf("%s:%d:%s:%s:%s", "webhook", connectionId, 
pipelineId, urlHash16, commitSha)
 }
 
 func CreateDeploymentAndDeploymentCommits(connection 
*models.WebhookConnection, request *WebhookDeployTaskRequest, tx 
dal.Transaction, logger log.Logger) errors.Error {
@@ -122,7 +122,7 @@ func CreateDeploymentAndDeploymentCommits(connection 
*models.WebhookConnection,
                // create a deployment_commit record
                deploymentCommit := &devops.CicdDeploymentCommit{
                        DomainEntity: domainlayer.DomainEntity{
-                               Id: generateDeploymentCommitId(connection.ID, 
request.RepoUrl, request.CommitSha),
+                               Id: GenerateDeploymentCommitId(connection.ID, 
request.PipelineId, request.RepoUrl, request.CommitSha),
                        },
                        CicdDeploymentId: request.PipelineId,
                        CicdScopeId:      scopeId,
@@ -157,7 +157,7 @@ func CreateDeploymentAndDeploymentCommits(connection 
*models.WebhookConnection,
                        // create a deployment_commit record
                        deploymentCommit := &devops.CicdDeploymentCommit{
                                DomainEntity: domainlayer.DomainEntity{
-                                       Id: 
generateDeploymentCommitId(connection.ID, commit.RepoUrl, commit.CommitSha),
+                                       Id: 
GenerateDeploymentCommitId(connection.ID, request.PipelineId, commit.RepoUrl, 
commit.CommitSha),
                                },
                                CicdDeploymentId: request.PipelineId,
                                CicdScopeId:      scopeId,

Reply via email to