From 7e0c605a3d470b8cee0e841e51da9b20022f4f4b Mon Sep 17 00:00:00 2001 From: hwen Date: Mon, 17 Jul 2023 16:50:45 +0800 Subject: [PATCH 1/4] [public-api] align context url with server --- components/public-api-server/pkg/apiv1/workspace.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/public-api-server/pkg/apiv1/workspace.go b/components/public-api-server/pkg/apiv1/workspace.go index 6bb367f4e172a9..2db2b37cc9f8f9 100644 --- a/components/public-api-server/pkg/apiv1/workspace.go +++ b/components/public-api-server/pkg/apiv1/workspace.go @@ -317,12 +317,18 @@ func convertWorkspaceInfo(input *protocol.WorkspaceInfo) (*v1.Workspace, error) if err != nil { return nil, err } + // Align to https://github.com/gitpod-io/gitpod/blob/0bb6aaad9d4923d5510de865437f22c7f726833f/components/server/src/workspace/workspace-starter.ts#L1375-L1378 + contextUrl := input.Workspace.ContextURL + if input.Workspace.Context != nil && len(input.Workspace.Context.NormalizedContextURL) > 0 { + contextUrl = input.Workspace.Context.NormalizedContextURL + } + return &v1.Workspace{ WorkspaceId: input.Workspace.ID, OwnerId: input.Workspace.OwnerID, ProjectId: "", Context: &v1.WorkspaceContext{ - ContextUrl: input.Workspace.ContextURL, + ContextUrl: contextUrl, Details: &v1.WorkspaceContext_Git_{Git: &v1.WorkspaceContext_Git{ NormalizedContextUrl: input.Workspace.ContextURL, Commit: "", From c302bb2a4e58b53d7db74533b7b0a5aed69a835a Mon Sep 17 00:00:00 2001 From: Huiwen Date: Mon, 17 Jul 2023 09:10:06 +0000 Subject: [PATCH 2/4] :lipstick: --- components/public-api-server/pkg/apiv1/workspace.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/components/public-api-server/pkg/apiv1/workspace.go b/components/public-api-server/pkg/apiv1/workspace.go index 2db2b37cc9f8f9..913d1646213432 100644 --- a/components/public-api-server/pkg/apiv1/workspace.go +++ b/components/public-api-server/pkg/apiv1/workspace.go @@ -317,20 +317,14 @@ func convertWorkspaceInfo(input *protocol.WorkspaceInfo) (*v1.Workspace, error) if err != nil { return nil, err } - // Align to https://github.com/gitpod-io/gitpod/blob/0bb6aaad9d4923d5510de865437f22c7f726833f/components/server/src/workspace/workspace-starter.ts#L1375-L1378 - contextUrl := input.Workspace.ContextURL - if input.Workspace.Context != nil && len(input.Workspace.Context.NormalizedContextURL) > 0 { - contextUrl = input.Workspace.Context.NormalizedContextURL - } - return &v1.Workspace{ WorkspaceId: input.Workspace.ID, OwnerId: input.Workspace.OwnerID, ProjectId: "", Context: &v1.WorkspaceContext{ - ContextUrl: contextUrl, + ContextUrl: input.Workspace.ContextURL, Details: &v1.WorkspaceContext_Git_{Git: &v1.WorkspaceContext_Git{ - NormalizedContextUrl: input.Workspace.ContextURL, + NormalizedContextUrl: input.Workspace.Context.NormalizedContextURL, Commit: "", }}, }, From b786e97ab4a717d8c123f87d963504fb681ad2f4 Mon Sep 17 00:00:00 2001 From: Huiwen Date: Mon, 17 Jul 2023 09:14:06 +0000 Subject: [PATCH 3/4] update test case --- components/public-api-server/pkg/apiv1/workspace_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/public-api-server/pkg/apiv1/workspace_test.go b/components/public-api-server/pkg/apiv1/workspace_test.go index 628a9974c6f768..8f50b877b948eb 100644 --- a/components/public-api-server/pkg/apiv1/workspace_test.go +++ b/components/public-api-server/pkg/apiv1/workspace_test.go @@ -662,7 +662,7 @@ var workspaceTestData = []workspaceTestDataEntry{ ContextUrl: "https://github.com/gitpod-io/gitpod", Details: &v1.WorkspaceContext_Git_{ Git: &v1.WorkspaceContext_Git{ - NormalizedContextUrl: "https://github.com/gitpod-io/gitpod", + NormalizedContextUrl: "https://github.com/gitpod-io/protocol.git", }, }, }, From 6d777e82dd7022693b599f43538c3bb59b1c8e96 Mon Sep 17 00:00:00 2001 From: Huiwen Date: Mon, 17 Jul 2023 17:08:08 +0000 Subject: [PATCH 4/4] Update test case --- components/public-api-server/pkg/apiv1/workspace_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/public-api-server/pkg/apiv1/workspace_test.go b/components/public-api-server/pkg/apiv1/workspace_test.go index 8f50b877b948eb..f37c351b71cdc5 100644 --- a/components/public-api-server/pkg/apiv1/workspace_test.go +++ b/components/public-api-server/pkg/apiv1/workspace_test.go @@ -613,9 +613,9 @@ var workspaceTestData = []workspaceTestDataEntry{ BaseImageNameResolved: "foo:bar", ID: "gitpodio-gitpod-isq6xj458lj", OwnerID: "fake-owner-id", - ContextURL: "https://github.com/gitpod-io/gitpod", + ContextURL: "open-prebuild/126ac54a-5922-4a45-9a18-670b057bf540/https://github.com/gitpod-io/gitpod/pull/18291", Context: &protocol.WorkspaceContext{ - NormalizedContextURL: "https://github.com/gitpod-io/protocol.git", + NormalizedContextURL: "https://github.com/gitpod-io/gitpod/pull/18291", Title: "tes ttitle", Repository: &protocol.Repository{ Host: "github.com", @@ -659,10 +659,10 @@ var workspaceTestData = []workspaceTestDataEntry{ WorkspaceId: "gitpodio-gitpod-isq6xj458lj", OwnerId: "fake-owner-id", Context: &v1.WorkspaceContext{ - ContextUrl: "https://github.com/gitpod-io/gitpod", + ContextUrl: "open-prebuild/126ac54a-5922-4a45-9a18-670b057bf540/https://github.com/gitpod-io/gitpod/pull/18291", Details: &v1.WorkspaceContext_Git_{ Git: &v1.WorkspaceContext_Git{ - NormalizedContextUrl: "https://github.com/gitpod-io/protocol.git", + NormalizedContextUrl: "https://github.com/gitpod-io/gitpod/pull/18291", }, }, },