Commit 1cccea4 1 parent 20a18fa commit 1cccea4 Copy full SHA for 1cccea4
File tree 3 files changed +21
-12
lines changed
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";
10
10
import { Workspace } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb" ;
11
11
import { useUpdateWorkspaceMutation } from "../data/workspaces/update-workspace-mutation" ;
12
12
import { LoadingButton } from "@podkit/buttons/LoadingButton" ;
13
+ import { Workspace as WorkspaceProtocol } from "@gitpod/gitpod-protocol" ;
13
14
14
- export const NAME_PREFIX = "named:" ;
15
15
export 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 ) ;
21
17
}
22
18
23
19
export 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 ) ;
28
21
}
29
22
30
23
type Props = {
Original file line number Diff line number Diff line change @@ -766,6 +766,20 @@ export namespace Workspace {
766
766
}
767
767
return undefined ;
768
768
}
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
+ }
769
783
}
770
784
771
785
export interface GuessGitTokenScopesParams {
Original file line number Diff line number Diff line change @@ -1587,10 +1587,12 @@ export class WorkspaceStarter {
1587
1587
sysEnvvars . push ( isSetJavaXmx ) ;
1588
1588
sysEnvvars . push ( isSetJavaProcessorCount ) ;
1589
1589
sysEnvvars . push ( disableJetBrainsLocalPortForwarding ) ;
1590
- if ( workspace . context . title ) {
1590
+
1591
+ const workspaceName = Workspace . fromWorkspaceName ( workspace . description ) ;
1592
+ if ( workspaceName && workspaceName . length > 0 ) {
1591
1593
const workspaceNameEnv = new EnvironmentVariable ( ) ;
1592
1594
workspaceNameEnv . setName ( "GITPOD_WORKSPACE_NAME" ) ;
1593
- workspaceNameEnv . setValue ( workspace . context . title ) ;
1595
+ workspaceNameEnv . setValue ( workspaceName ) ;
1594
1596
sysEnvvars . push ( workspaceNameEnv ) ;
1595
1597
}
1596
1598
const spec = new StartWorkspaceSpec ( ) ;
You can’t perform that action at this time.
0 commit comments