File tree Expand file tree Collapse file tree 3 files changed +21
-12
lines changed Expand file tree Collapse file tree 3 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -10,21 +10,14 @@ import { Button } from "@podkit/buttons/Button";
1010import { Workspace } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb" ;
1111import { useUpdateWorkspaceMutation } from "../data/workspaces/update-workspace-mutation" ;
1212import { LoadingButton } from "@podkit/buttons/LoadingButton" ;
13+ import { Workspace as WorkspaceProtocol } from "@gitpod/gitpod-protocol" ;
1314
14- export const NAME_PREFIX = "named:" ;
1515export function toWorkspaceName ( name : string ) : string {
16- // unsetting the name
17- if ( name . trim ( ) . length === 0 ) {
18- return "no-name" ;
19- }
20- return `${ NAME_PREFIX } ${ name } ` ;
16+ return WorkspaceProtocol . toWorkspaceName ( name ) ;
2117}
2218
2319export function fromWorkspaceName ( workspace ?: Workspace ) : string | undefined {
24- if ( workspace ?. metadata ?. name ?. startsWith ( NAME_PREFIX ) ) {
25- return workspace . metadata . name . slice ( NAME_PREFIX . length ) ;
26- }
27- return undefined ;
20+ return WorkspaceProtocol . fromWorkspaceName ( workspace ?. metadata ?. name ) ;
2821}
2922
3023type Props = {
Original file line number Diff line number Diff line change @@ -766,6 +766,20 @@ export namespace Workspace {
766766 }
767767 return undefined ;
768768 }
769+
770+ const NAME_PREFIX = "named:" ;
771+ export function fromWorkspaceName ( name ?: Workspace [ "description" ] ) : string | undefined {
772+ if ( name ?. startsWith ( NAME_PREFIX ) ) {
773+ return name . slice ( NAME_PREFIX . length ) ;
774+ }
775+ return undefined ;
776+ }
777+ export function toWorkspaceName ( name ?: Workspace [ "description" ] ) : string {
778+ if ( ! name || name ?. trim ( ) . length === 0 ) {
779+ return "no-name" ;
780+ }
781+ return `${ NAME_PREFIX } ${ name } ` ;
782+ }
769783}
770784
771785export interface GuessGitTokenScopesParams {
Original file line number Diff line number Diff line change @@ -1587,10 +1587,12 @@ export class WorkspaceStarter {
15871587 sysEnvvars . push ( isSetJavaXmx ) ;
15881588 sysEnvvars . push ( isSetJavaProcessorCount ) ;
15891589 sysEnvvars . push ( disableJetBrainsLocalPortForwarding ) ;
1590- if ( workspace . context . title ) {
1590+
1591+ const workspaceName = Workspace . fromWorkspaceName ( workspace . description ) ;
1592+ if ( workspaceName && workspaceName . length > 0 ) {
15911593 const workspaceNameEnv = new EnvironmentVariable ( ) ;
15921594 workspaceNameEnv . setName ( "GITPOD_WORKSPACE_NAME" ) ;
1593- workspaceNameEnv . setValue ( workspace . context . title ) ;
1595+ workspaceNameEnv . setValue ( workspaceName ) ;
15941596 sysEnvvars . push ( workspaceNameEnv ) ;
15951597 }
15961598 const spec = new StartWorkspaceSpec ( ) ;
You can’t perform that action at this time.
0 commit comments