Kaynağa Gözat

fix git repo branches output from env type

Mohammed Nafees 3 yıl önce
ebeveyn
işleme
30e9f8f0ef
1 değiştirilmiş dosya ile 11 ekleme ve 2 silme
  1. 11 2
      internal/models/environment.go

+ 11 - 2
internal/models/environment.go

@@ -50,20 +50,29 @@ func getGitRepoBranches(branches string) []string {
 }
 
 func (e *Environment) ToEnvironmentType() *types.Environment {
-	return &types.Environment{
+	envType := &types.Environment{
 		ID:                e.Model.ID,
 		ProjectID:         e.ProjectID,
 		ClusterID:         e.ClusterID,
 		GitInstallationID: e.GitInstallationID,
 		GitRepoOwner:      e.GitRepoOwner,
 		GitRepoName:       e.GitRepoName,
-		GitRepoBranches:   getGitRepoBranches(e.GitRepoBranches),
 
 		NewCommentsDisabled: e.NewCommentsDisabled,
 
 		Name: e.Name,
 		Mode: e.Mode,
 	}
+
+	branches := getGitRepoBranches(e.GitRepoBranches)
+
+	if len(branches) > 0 {
+		envType.GitRepoBranches = branches
+	} else {
+		envType.GitRepoBranches = []string{}
+	}
+
+	return envType
 }
 
 type Deployment struct {