Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 786ef83

Browse files
committed
Checks date for any RA
1 parent a22aeb2 commit 786ef83

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

src/tools/rust-analyzer/editors/code/src/bootstrap.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,16 @@ function orderFromPath(
154154
raVersionResolver: (path: string) => string | undefined,
155155
): string {
156156
const capture = path.match(/^.*\/toolchains\/(.*)\/bin\/rust-analyzer$/);
157-
158157
if (capture?.length === 2) {
159158
const toolchain = capture[1]!;
160-
if (toolchain.startsWith("stable-")) {
161-
return "1";
159+
// It is a semver, so we must resolve Rust Analyzer's version.
160+
const raVersion = raVersionResolver(path);
161+
const raDate = raVersion?.match(/^rust-analyzer .*\(.* (\d{4}-\d{2}-\d{2})\)$/);
162+
if (raDate?.length === 2) {
163+
const precedence = toolchain.startsWith("nightly-") ? "/0" : "/1";
164+
return "0-" + raDate[1] + precedence;
162165
} else {
163-
// It is a semver, so we must resolve Rust Analyzer's version.
164-
const raVersion = raVersionResolver(path);
165-
const raDate = raVersion?.match(/^rust-analyzer .*\(.* (\d{4}-\d{2}-\d{2})\)$/);
166-
if (raDate?.length === 2) {
167-
const precedence = toolchain.startsWith("nightly-") ? "/0" : "/1";
168-
return "0-" + raDate[1] + precedence;
169-
} else {
170-
return "2";
171-
}
166+
return "2";
172167
}
173168
} else {
174169
return "2";

src/tools/rust-analyzer/editors/code/tests/unit/bootstrap.test.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ export async function getTests(ctx: Context) {
5252
assert.deepStrictEqual(
5353
_private.orderFromPath(
5454
"/Users/myuser/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rust-analyzer",
55-
function () {
56-
assert.fail("Shouldn't get here.");
55+
function (path: string) {
56+
assert.deepStrictEqual(
57+
path,
58+
"/Users/myuser/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rust-analyzer",
59+
);
60+
return "rust-analyzer 1.79.0 (129f3b99 2024-06-10)";
5761
},
5862
),
59-
"1",
63+
"0-2024-06-10/1",
6064
);
6165
});
6266

@@ -75,11 +79,14 @@ export async function getTests(ctx: Context) {
7579
"/Users/myuser/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rust-analyzer",
7680
"/Users/myuser/.rustup/toolchains/nightly-2022-11-22-aarch64-apple-darwin/bin/rust-analyzer",
7781
function (path: string) {
78-
assert.deepStrictEqual(
79-
path,
80-
"/Users/myuser/.rustup/toolchains/nightly-2022-11-22-aarch64-apple-darwin/bin/rust-analyzer",
81-
);
82-
return "rust-analyzer 1.67.0-nightly (b7bc90fe 2022-11-21)";
82+
if (
83+
path ===
84+
"/Users/myuser/.rustup/toolchains/nightly-2022-11-22-aarch64-apple-darwin/bin/rust-analyzer"
85+
) {
86+
return "rust-analyzer 1.67.0-nightly (b7bc90fe 2022-11-21)";
87+
} else {
88+
return "rust-analyzer 1.79.0 (129f3b99 2024-06-10)";
89+
}
8390
},
8491
),
8592
"/Users/myuser/.rustup/toolchains/nightly-2022-11-22-aarch64-apple-darwin/bin/rust-analyzer",

0 commit comments

Comments
 (0)