Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for versions greater than 2.3.3 for the log-dir flag #168

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { getHeaderCommand } from "./headers"
import { SSHConfig, SSHValues, defaultSSHConfigResponse, mergeSSHConfigValues } from "./sshConfig"
import { computeSSHProperties, sshSupportsSetEnv } from "./sshSupport"
import { Storage } from "./storage"
import { supportsCoderAgentLogDirFlag } from "./version"
import { WorkspaceAction } from "./workspaceAction"

export class Remote {
Expand Down Expand Up @@ -76,10 +77,7 @@ export class Remote {
await this.closeRemote()
return
}
// CLI versions before 2.3.3 don't support the --log-dir flag!
// If this check didn't exist, VS Code connections would fail on
// older versions because of an unknown CLI argument.
const hasCoderLogs = (parsedVersion?.compare("2.3.3") || 0) >= 0 || parsedVersion?.prerelease[0] === "devel"
const hasCoderLogs = supportsCoderAgentLogDirFlag(parsedVersion)

// Find the workspace from the URI scheme provided!
try {
Expand Down
13 changes: 13 additions & 0 deletions src/version.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { parse } from "semver"
import { describe, expect, it } from "vitest"
import { supportsCoderAgentLogDirFlag } from "./version"

describe("check version support", () => {
it("has logs", () => {
expect(supportsCoderAgentLogDirFlag(parse("v1.3.3+e491217"))).toBeFalsy()
expect(supportsCoderAgentLogDirFlag(parse("v2.3.3+e491217"))).toBeFalsy()
expect(supportsCoderAgentLogDirFlag(parse("v2.3.4+e491217"))).toBeTruthy()
expect(supportsCoderAgentLogDirFlag(parse("v5.3.4+e491217"))).toBeTruthy()
expect(supportsCoderAgentLogDirFlag(parse("v5.0.4+e491217"))).toBeTruthy()
})
})
8 changes: 8 additions & 0 deletions src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SemVer } from "semver"

// CLI versions before 2.3.3 don't support the --log-dir flag!
// If this check didn't exist, VS Code connections would fail on
// older versions because of an unknown CLI argument.
export const supportsCoderAgentLogDirFlag = (ver: SemVer | null): boolean => {
return (ver?.compare("2.3.3") || 0) > 0 || ver?.prerelease[0] === "devel"
}