You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ly...@apache.org on 2024/09/10 08:36:39 UTC

(incubator-devlake) branch main updated: fix: deployment name too long when commits are too many (#8024)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 054b2f5e6 fix: deployment name too long when commits are too many (#8024)
054b2f5e6 is described below

commit 054b2f5e62ee110ea2f3cafea7374d296f4b6c3d
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Tue Sep 10 16:36:34 2024 +0800

    fix: deployment name too long when commits are too many (#8024)
---
 backend/plugins/webhook/api/deployments.go | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/backend/plugins/webhook/api/deployments.go b/backend/plugins/webhook/api/deployments.go
index 70c90f9e2..366cf11b7 100644
--- a/backend/plugins/webhook/api/deployments.go
+++ b/backend/plugins/webhook/api/deployments.go
@@ -21,7 +21,6 @@ import (
 	"crypto/md5"
 	"fmt"
 	"net/http"
-	"strings"
 	"time"
 
 	"github.com/apache/incubator-devlake/core/dal"
@@ -135,20 +134,16 @@ func CreateDeploymentAndDeploymentCommits(connection *models.WebhookConnection,
 		request.Environment = devops.PRODUCTION
 	}
 	duration := float64(request.FinishedDate.Sub(*request.StartedDate).Milliseconds() / 1e3)
-	name := request.Name
-	if name == "" {
-		var commitShaList []string
-		for _, commit := range request.DeploymentCommits {
-			commitShaList = append(commitShaList, commit.CommitSha)
-		}
-		name = fmt.Sprintf(`deploy %s to %s`, strings.Join(commitShaList, ","), request.Environment)
-	}
 	createdDate := time.Now()
 	if request.CreatedDate != nil {
 		createdDate = *request.CreatedDate
 	} else if request.StartedDate != nil {
 		createdDate = *request.StartedDate
 	}
+	name := request.Name
+	if name == "" {
+		name = fmt.Sprintf(`deploy to %s at %s`, request.Environment, createdDate.Format(time.RFC3339))
+	}
 
 	// prepare deploymentCommits and deployment records
 	// queuedDuration := dateInfo.CalculateQueueDuration()