Skip to content

Commit

Permalink
fix when base is .
Browse files Browse the repository at this point in the history
  • Loading branch information
mafredri committed Oct 4, 2024
1 parent 2504314 commit 381bf73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,15 +844,17 @@ func TestContainerEnv(t *testing.T) {
require.NoError(t, err)

output := execContainer(t, ctr, "cat /env")
require.Contains(t, strings.TrimSpace(output),
`DEVCONTAINER=true
want := `DEVCONTAINER=true
DEVCONTAINER_CONFIG=/workspaces/empty/.devcontainer/devcontainer.json
ENVBUILDER=true
FROM_CONTAINER_ENV=bar
FROM_DOCKERFILE=foo
FROM_REMOTE_ENV=baz
PATH=/usr/local/bin:/bin:/go/bin:/opt
REMOTE_BAR=bar`)
REMOTE_BAR=bar`
if diff := cmp.Diff(want, strings.TrimSpace(output)); diff != "" {
require.Failf(t, "env mismatch", "diff (-want +got):\n%s", diff)
}
}

func TestUnsetOptionsEnv(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion options/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func DefaultWorkspaceFolder(repoURL string) string {
// Giturls parsing never actually fails since ParseLocal never
// errors and places the entire URL in the Path field. This check
// ensures it's at least a Unix path containing forwardslash.
if repo == repoURL || repo == "" {
if repo == repoURL || repo == "." || repo == "" {
return EmptyWorkspaceDir
}
repo = strings.TrimSuffix(repo, ".git")
Expand Down
4 changes: 4 additions & 0 deletions options/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ func TestDefaultWorkspaceFolder(t *testing.T) {
name: "Unix root",
invalidURL: "/",
},
{
name: "Git URL with no path",
invalidURL: "http://127.0.0.1:41073",
},
}
for _, tt := range invalidTests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 381bf73

Please sign in to comment.