From 4d8a9e9625b5f9cbf5a388682c0dc1193075b39f Mon Sep 17 00:00:00 2001 From: Cheng Date: Tue, 25 Apr 2023 17:34:03 +0800 Subject: [PATCH 1/3] fix(lookupByPath): prefixMatch handles last single char segment --- libraries/rush-lib/src/logic/LookupByPath.ts | 2 +- libraries/rush-lib/src/logic/test/LookupByPath.test.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/rush-lib/src/logic/LookupByPath.ts b/libraries/rush-lib/src/logic/LookupByPath.ts index a848949f216..ce209f909e4 100644 --- a/libraries/rush-lib/src/logic/LookupByPath.ts +++ b/libraries/rush-lib/src/logic/LookupByPath.ts @@ -111,7 +111,7 @@ export class LookupByPath { } // Last segment - if (previousIndex + 1 < input.length) { + if (previousIndex < input.length) { yield { prefix: input.slice(previousIndex, input.length), index: input.length diff --git a/libraries/rush-lib/src/logic/test/LookupByPath.test.ts b/libraries/rush-lib/src/logic/test/LookupByPath.test.ts index 5b4cbeed881..2d56d082d58 100644 --- a/libraries/rush-lib/src/logic/test/LookupByPath.test.ts +++ b/libraries/rush-lib/src/logic/test/LookupByPath.test.ts @@ -20,6 +20,10 @@ describe(LookupByPath.iteratePathSegments.name, () => { const result = [...LookupByPath.iteratePathSegments('foo/bar/baz')]; expect(result).toEqual(['foo', 'bar', 'baz']); }); + it('returns correct last single character segment', () => { + const result = [...LookupByPath.iteratePathSegments('foo/a')]; + expect(result).toEqual(['foo', 'a']); + }); }); describe(LookupByPath.prototype.findChildPath.name, () => { From 20a52764ee4a126e346301fc7e1b6b7d37fbb396 Mon Sep 17 00:00:00 2001 From: Cheng Date: Tue, 25 Apr 2023 17:41:49 +0800 Subject: [PATCH 2/3] chore: rush change --- .../rush/fix-look-by-path_2023-04-25-09-41.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json diff --git a/common/changes/@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json b/common/changes/@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json new file mode 100644 index 00000000000..2d42df6e826 --- /dev/null +++ b/common/changes/@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Correctly match the prefix with the last single character segment", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file From bd90f83eef83a6bd3c0e90389ffe3ce2da2eea2a Mon Sep 17 00:00:00 2001 From: Cheng Date: Tue, 25 Apr 2023 19:50:01 +0800 Subject: [PATCH 3/3] Update common/changes/@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json Co-authored-by: Ian Clanton-Thuon --- .../@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/changes/@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json b/common/changes/@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json index 2d42df6e826..d5b4c94712a 100644 --- a/common/changes/@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json +++ b/common/changes/@microsoft/rush/fix-look-by-path_2023-04-25-09-41.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@microsoft/rush", - "comment": "Correctly match the prefix with the last single character segment", + "comment": "Fix an issue where the last character in a project's path is ignored when determining which files contribute to the project's cache ID.", "type": "none" } ],