Skip to content

Commit 98cf7b2

Browse files
committed
fix(ssh): ignore implicit dotfile Include matches
1 parent 9e85538 commit 98cf7b2

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎packages/ssh/src/config.test.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe("ssh config", () => {
5656
}).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
5757
);
5858

59-
it.effect("skips directory Include matches without losing file aliases or known hosts", () =>
59+
it.effect("skips directories and implicit dotfile Include matches but keeps explicit ones", () =>
6060
Effect.gen(function* () {
6161
const fs = yield* FileSystem.FileSystem;
6262
const path = yield* Path.Path;
@@ -66,12 +66,24 @@ describe("ssh config", () => {
6666
yield* fs.makeDirectory(path.join(sshDir, "explicit-directory"));
6767
yield* fs.writeFileString(
6868
path.join(sshDir, "config"),
69-
"Include config.d/*\nInclude explicit-directory\nHost real\n HostName real.example.com\n",
69+
"Include config.d/*\nInclude config.d/.literal.conf\nInclude config.d/.enabled-*.conf\nInclude explicit-directory\nHost real\n HostName real.example.com\n",
7070
);
7171
yield* fs.writeFileString(
7272
path.join(sshDir, "config.d", "team.conf"),
7373
"Host team\n HostName team.example.com\n",
7474
);
75+
yield* fs.writeFileString(
76+
path.join(sshDir, "config.d", ".backup.conf"),
77+
"Host *\n HostName obsolete.example.com\n",
78+
);
79+
yield* fs.writeFileString(
80+
path.join(sshDir, "config.d", ".literal.conf"),
81+
"Host literal\n HostName literal.example.com\n",
82+
);
83+
yield* fs.writeFileString(
84+
path.join(sshDir, "config.d", ".enabled-one.conf"),
85+
"Host enabled\n HostName enabled.example.com\n",
86+
);
7587
yield* fs.writeFileString(
7688
path.join(sshDir, "known_hosts"),
7789
"known.example.com ssh-ed25519 AAAA\n",
@@ -81,7 +93,9 @@ describe("ssh config", () => {
8193
assert.deepEqual(
8294
hosts.map((host) => [host.alias, host.hostname, host.source]),
8395
[
96+
["enabled", "enabled.example.com", "ssh-config"],
8497
["known.example.com", "known.example.com", "known-hosts"],
98+
["literal", "literal.example.com", "ssh-config"],
8599
["real", "real.example.com", "ssh-config"],
86100
["team", "team.example.com", "ssh-config"],
87101
],

‎packages/ssh/src/config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const expandGlob = Effect.fnUntraced(function* (pattern: string) {
112112
const entries = yield* fs.readDirectory(directory);
113113
const matchedPaths: string[] = [];
114114
for (const entry of entries) {
115+
if (entry.startsWith(".") && !basePattern.startsWith(".")) continue;
115116
if (!matcher.test(entry)) {
116117
continue;
117118
}

0 commit comments

Comments
 (0)