Skip to content

Commit f8ef5b7

Browse files
committed
Fix previewctl get-name
1 parent aba04a0 commit f8ef5b7

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Diff for: dev/image/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
FROM gitpod/workspace-full:2022-10-15-02-50-27
66

7-
ENV TRIGGER_REBUILD 23
7+
ENV TRIGGER_REBUILD 24
88

99
USER root
1010

Diff for: dev/preview/previewctl/pkg/preview/preview.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ func New(branch string, logger *logrus.Logger) (*Preview, error) {
4646
return nil, err
4747
}
4848

49-
branch = strings.TrimRight(branch, "\n")
50-
5149
logEntry := logger.WithFields(logrus.Fields{"branch": branch})
5250

5351
harvesterConfig, err := k8s.NewFromDefaultConfigWithContext(logEntry.Logger, harvesterContextName)
@@ -191,6 +189,7 @@ func GetName(branch string) (string, error) {
191189
}
192190
}
193191

192+
branch = strings.TrimSpace(branch)
194193
withoutRefsHead := strings.Replace(branch, "/refs/heads/", "", 1)
195194
lowerCased := strings.ToLower(withoutRefsHead)
196195

Diff for: dev/preview/previewctl/pkg/preview/preview_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ func TestGetPreviewName(t *testing.T) {
4242
branch: "/refs/heads/this-is-a-long-branch-that-should-be-replaced-with-a-hash",
4343
expectedResult: "this-is-a-a868caa3c3",
4444
},
45+
{
46+
testName: "branch-with-space",
47+
branch: "/refs/heads/jetbrains/backend-plugin-platform-2 ",
48+
expectedResult: "jetbrains-35a989462b",
49+
},
4550
}
4651

4752
for _, tc := range testCases {

0 commit comments

Comments
 (0)