From aa1a328c00a692f438b5eb1dcbc20a86c21566eb Mon Sep 17 00:00:00 2001 From: Jack Lewin <14926880+jack-lewin@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:33:54 +0100 Subject: [PATCH 01/11] Add additionalPaths property --- src/manifest.ts | 5 ++++ .../manifest/config/additional-paths.json | 8 ++++++ test/manifest.ts | 28 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 test/fixtures/manifest/config/additional-paths.json diff --git a/src/manifest.ts b/src/manifest.ts index 10ac85748..3968bf0a3 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -137,6 +137,7 @@ export interface ReleaserConfig { skipSnapshot?: boolean; // Manifest only excludePaths?: string[]; + additionalPaths?: string[]; } export interface CandidateReleasePullRequest { @@ -183,6 +184,7 @@ interface ReleaserConfigJson { 'skip-snapshot'?: boolean; // Java-only 'initial-version'?: string; 'exclude-paths'?: string[]; // manifest-only + 'additional-paths'?: string[]; // manifest-only } export interface ManifestOptions { @@ -1372,6 +1374,7 @@ function extractReleaserConfig( skipSnapshot: config['skip-snapshot'], initialVersion: config['initial-version'], excludePaths: config['exclude-paths'], + additionalPaths: config['additional-paths'], signoff: config['signoff'], }; } @@ -1727,6 +1730,8 @@ function mergeReleaserConfig( initialVersion: pathConfig.initialVersion ?? defaultConfig.initialVersion, extraLabels: pathConfig.extraLabels ?? defaultConfig.extraLabels, excludePaths: pathConfig.excludePaths ?? defaultConfig.excludePaths, + additionalPaths: + pathConfig.additionalPaths ?? defaultConfig.additionalPaths, }; } diff --git a/test/fixtures/manifest/config/additional-paths.json b/test/fixtures/manifest/config/additional-paths.json new file mode 100644 index 000000000..7e7d380e8 --- /dev/null +++ b/test/fixtures/manifest/config/additional-paths.json @@ -0,0 +1,8 @@ +{ + "release-type": "simple", + "packages": { + "apps/my-app": { + "additional-paths": ["libs/my-lib"] + } + } +} diff --git a/test/manifest.ts b/test/manifest.ts index 7315dee0c..74fde9ddb 100644 --- a/test/manifest.ts +++ b/test/manifest.ts @@ -535,6 +535,34 @@ describe('Manifest', () => { 'path-ignore', ]); }); + it('should read additional paths from manifest', async () => { + const getFileContentsStub = sandbox.stub( + github, + 'getFileContentsOnBranch' + ); + getFileContentsStub + .withArgs('release-please-config.json', 'main') + .resolves( + buildGitHubFileContent( + fixturesPath, + 'manifest/config/additional-paths.json' + ) + ) + .withArgs('.release-please-manifest.json', 'main') + .resolves( + buildGitHubFileContent( + fixturesPath, + 'manifest/versions/versions.json' + ) + ); + const manifest = await Manifest.fromManifest( + github, + github.repository.defaultBranch + ); + expect( + manifest.repositoryConfig['apps/my-app'].additionalPaths + ).to.deep.equal(['libs/my-lib']); + }); it('should build simple plugins from manifest', async () => { const getFileContentsStub = sandbox.stub( github, From 01b7252c19a77230a5338c6048e2eeae47f4c021 Mon Sep 17 00:00:00 2001 From: Jack Lewin <14926880+jack-lewin@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:34:12 +0100 Subject: [PATCH 02/11] Update CommitSplit to accept additionalPaths Before, packagePaths was an array of strings, i.e. the name of each package. Now, packagePaths is a Record, with the key being the name of each package, and the value being an aray of additionalPaths for that package. --- src/manifest.ts | 7 ++++++- src/util/commit-split.ts | 35 ++++++++++++++++++++++------------- test/util/commit-split.ts | 8 ++++---- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/manifest.ts b/src/manifest.ts index 3968bf0a3..f8ef43e0e 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -660,7 +660,12 @@ export class Manifest { this.logger.info(`Splitting ${commits.length} commits by path`); const cs = new CommitSplit({ includeEmpty: true, - packagePaths: Object.keys(this.repositoryConfig), + packagePaths: Object.fromEntries( + Object.entries(this.repositoryConfig).map(([path, config]) => [ + path, + config.additionalPaths || [], + ]) + ), }); const splitCommits = cs.split(commits); diff --git a/src/util/commit-split.ts b/src/util/commit-split.ts index c8a2d5648..ff1c00b41 100644 --- a/src/util/commit-split.ts +++ b/src/util/commit-split.ts @@ -39,7 +39,7 @@ export interface CommitSplitOptions { // // NOTE: GitHub API always returns paths using the `/` separator, regardless // of what platform the client code is running on - packagePaths?: string[]; + packagePaths?: Record; } /** @@ -50,19 +50,24 @@ export interface CommitSplitOptions { */ export class CommitSplit { includeEmpty: boolean; - packagePaths?: string[]; + packagePaths?: Record; constructor(opts?: CommitSplitOptions) { opts = opts || {}; this.includeEmpty = !!opts.includeEmpty; if (opts.packagePaths) { - const paths: string[] = normalizePaths(opts.packagePaths); - this.packagePaths = paths - .filter(path => { - // The special "." path, representing the root of the module, should be - // ignored by commit-split as it is assigned all commits in manifest.ts - return path !== ROOT_PROJECT_PATH; - }) - .sort((a, b) => b.length - a.length); // sort by longest paths first + this.packagePaths = Object.fromEntries( + Object.entries(opts.packagePaths) + .map(([path, additionalPaths]) => [ + normalizePaths([path]).pop(), + normalizePaths(additionalPaths), + ]) + .filter(([path]) => { + // The special "." path, representing the root of the module, should be + // ignored by commit-split as it is assigned all commits in manifest.ts + return path !== ROOT_PROJECT_PATH; + }) + .sort(([a], [b]) => b.length - a.length) // sort by longest paths first + ); } } @@ -93,10 +98,14 @@ export class CommitSplit { // in this edge-case we should not attempt to update the path. if (splitPath.length === 1) continue; - let pkgName; + let pkgName: string | undefined; if (this.packagePaths) { // only track paths under this.packagePaths - pkgName = this.packagePaths.find(p => file.indexOf(`${p}/`) === 0); + pkgName = Object.entries(this.packagePaths).find( + ([path, additionalPaths]) => + file.indexOf(`${path}/`) === 0 || + additionalPaths.some(path => file.indexOf(`${path}/`) === 0) + )?.[0]; } else { // track paths by top level folder pkgName = splitPath[0]; @@ -108,7 +117,7 @@ export class CommitSplit { } if (commit.files.length === 0 && this.includeEmpty) { if (this.packagePaths) { - for (const pkgName of this.packagePaths) { + for (const pkgName of Object.keys(this.packagePaths)) { splitCommits[pkgName] = splitCommits[pkgName] || []; splitCommits[pkgName].push(commit); } diff --git a/test/util/commit-split.ts b/test/util/commit-split.ts index a8ea1ccf9..99a531f76 100644 --- a/test/util/commit-split.ts +++ b/test/util/commit-split.ts @@ -46,7 +46,7 @@ describe('CommitSplit', () => { }); it('uses path prefixes', () => { const commitSplit = new CommitSplit({ - packagePaths: ['pkg5', 'pkg6/pkg5'], + packagePaths: {pkg5: [], 'pkg6/pkg5': []}, }); const splitCommits = commitSplit.split(commits); expect(splitCommits['pkg1']).to.be.undefined; @@ -70,7 +70,7 @@ describe('CommitSplit', () => { }, ]; const commitSplit = new CommitSplit({ - packagePaths: ['core', 'core/subpackage'], + packagePaths: {core: [], 'core/subpackage': []}, }); const splitCommits = commitSplit.split(commits); expect(splitCommits['core']).lengthOf(1); @@ -90,7 +90,7 @@ describe('CommitSplit', () => { it('should separate commits with limited list of paths', () => { const commitSplit = new CommitSplit({ includeEmpty: true, - packagePaths: ['pkg1', 'pkg4'], + packagePaths: {pkg1: [], pkg4: []}, }); const splitCommits = commitSplit.split(commits); expect(splitCommits['pkg1']).lengthOf(3); @@ -114,7 +114,7 @@ describe('CommitSplit', () => { it('should separate commits with limited list of paths', () => { const commitSplit = new CommitSplit({ includeEmpty: false, - packagePaths: ['pkg1', 'pkg4'], + packagePaths: {pkg1: [], pkg4: []}, }); const splitCommits = commitSplit.split(commits); expect(splitCommits['pkg1']).lengthOf(2); From 5f39dc1f9190b8f1d3b02cd42c6880fd9b571962 Mon Sep 17 00:00:00 2001 From: Jack Lewin <14926880+jack-lewin@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:34:48 +0100 Subject: [PATCH 03/11] Add normalizePath along existing normalizePaths util --- src/util/commit-split.ts | 4 ++-- src/util/commit-utils.ts | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/util/commit-split.ts b/src/util/commit-split.ts index ff1c00b41..f9ab6581c 100644 --- a/src/util/commit-split.ts +++ b/src/util/commit-split.ts @@ -14,7 +14,7 @@ import {Commit} from '../commit'; import {ROOT_PROJECT_PATH} from '../manifest'; -import {normalizePaths} from './commit-utils'; +import {normalizePath, normalizePaths} from './commit-utils'; export interface CommitSplitOptions { // Include empty git commits: each empty commit is included @@ -58,7 +58,7 @@ export class CommitSplit { this.packagePaths = Object.fromEntries( Object.entries(opts.packagePaths) .map(([path, additionalPaths]) => [ - normalizePaths([path]).pop(), + normalizePath(path), normalizePaths(additionalPaths), ]) .filter(([path]) => { diff --git a/src/util/commit-utils.ts b/src/util/commit-utils.ts index 9e2842763..15c230ef4 100644 --- a/src/util/commit-utils.ts +++ b/src/util/commit-utils.ts @@ -13,18 +13,20 @@ // limitations under the License. export const normalizePaths = (paths: string[]) => { - return paths.map(path => { - // normalize so that all paths have leading and trailing slashes for - // non-overlap validation. - // NOTE: GitHub API always returns paths using the `/` separator, - // regardless of what platform the client code is running on - let newPath = path.replace(/\/$/, ''); - newPath = newPath.replace(/^\//, ''); - newPath = newPath.replace(/$/, '/'); - newPath = newPath.replace(/^/, '/'); - // store them with leading and trailing slashes removed. - newPath = newPath.replace(/\/$/, ''); - newPath = newPath.replace(/^\//, ''); - return newPath; - }); + return paths.map(normalizePath); +}; + +export const normalizePath = (path: string) => { + // normalize so that all paths have leading and trailing slashes for + // non-overlap validation. + // NOTE: GitHub API always returns paths using the `/` separator, + // regardless of what platform the client code is running on + let newPath = path.replace(/\/$/, ''); + newPath = newPath.replace(/^\//, ''); + newPath = newPath.replace(/$/, '/'); + newPath = newPath.replace(/^/, '/'); + // store them with leading and trailing slashes removed. + newPath = newPath.replace(/\/$/, ''); + newPath = newPath.replace(/^\//, ''); + return newPath; }; From 6624dc071eade745ad65c53f55f905bbb03a45be Mon Sep 17 00:00:00 2001 From: Jack Lewin <14926880+jack-lewin@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:35:05 +0100 Subject: [PATCH 04/11] Add test for additional-paths --- test/manifest.ts | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/manifest.ts b/test/manifest.ts index 74fde9ddb..c53f59441 100644 --- a/test/manifest.ts +++ b/test/manifest.ts @@ -3547,6 +3547,59 @@ describe('Manifest', () => { ); }); }); + + it('should update manifest for commits in additionalPaths', async () => { + mockReleases(sandbox, github, []); + mockTags(sandbox, github, [ + { + name: 'apps-myapp-v1.0.0', + sha: 'abc123', + }, + ]); + mockCommits(sandbox, github, [ + { + sha: 'aaaaaa', + message: 'fix: my-lib bugfix', + files: ['libs/my-lib/test.txt'], + }, + { + sha: 'abc123', + message: 'chore: release main', + files: [], + pullRequest: { + headBranchName: 'release-please/branches/main/components/myapp', + baseBranchName: 'main', + number: 123, + title: 'chore: release main', + body: '', + labels: [], + files: [], + sha: 'abc123', + }, + }, + ]); + const manifest = new Manifest( + github, + 'main', + { + 'apps/my-app': { + releaseType: 'simple', + component: 'myapp', + additionalPaths: ['libs/my-lib'], + }, + }, + { + 'apps/my-app': Version.parse('1.0.0'), + } + ); + const pullRequests = await manifest.buildPullRequests(); + expect(pullRequests).lengthOf(1); + const pullRequest = pullRequests[0]; + expect(pullRequest.version?.toString()).to.eql('1.0.1'); + expect(pullRequest.headRefName).to.eql( + 'release-please--branches--main--components--myapp' + ); + }); }); describe('createPullRequests', () => { From 654150b0c41c1deb63c7ed8219f6194d7b61a60d Mon Sep 17 00:00:00 2001 From: Jack Lewin <14926880+jack-lewin@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:35:21 +0100 Subject: [PATCH 05/11] Add docs for additional-paths --- docs/manifest-releaser.md | 2 ++ schemas/config.json | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/manifest-releaser.md b/docs/manifest-releaser.md index cfc3e0248..b651170b4 100644 --- a/docs/manifest-releaser.md +++ b/docs/manifest-releaser.md @@ -267,6 +267,8 @@ defaults (those are documented in comments) "release-type": "node", // exclude commits from that path from processing "exclude-paths": ["path/to/myPyPkgA"] + // include commits from that path in processing + "additional-paths": ["path/to/externalPkgB"] }, // path segment should be relative to repository root diff --git a/schemas/config.json b/schemas/config.json index 2477278a5..c1607153e 100644 --- a/schemas/config.json +++ b/schemas/config.json @@ -199,6 +199,13 @@ "type": "string" } }, + "additional-paths": { + "description": "Path of commits, from outside the package, to be included in parsing.", + "type": "array", + "items": { + "type": "string" + } + }, "version-file": { "description": "Path to the specialize version file. Used by `ruby` and `simple` strategies.", "type": "string" @@ -443,6 +450,7 @@ "version-file": true, "snapshot-label": true, "initial-version": true, - "exclude-paths": true + "exclude-paths": true, + "additional-paths": true } } From 60ab9eb4195e01b8d42b5c46d542b46091de7603 Mon Sep 17 00:00:00 2001 From: Jack Lewin <14926880+jack-lewin@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:35:35 +0100 Subject: [PATCH 06/11] Reword extra-files description for clarity --- __snapshots__/cli.js | 2 +- docs/cli.md | 4 ++-- src/bin/release-please.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__snapshots__/cli.js b/__snapshots__/cli.js index 60389f1fa..216336746 100644 --- a/__snapshots__/cli.js +++ b/__snapshots__/cli.js @@ -190,7 +190,7 @@ Options: the first major release [boolean] [default: false] --prerelease-type type of the prerelease, e.g., alpha [string] - --extra-files extra files for the strategy to consider + --extra-files extra files for the strategy to update [string] --version-file path to version file to update, e.g., version.rb [string] diff --git a/docs/cli.md b/docs/cli.md index d6a6abedd..b527d6c0c 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -64,7 +64,7 @@ Extra options: | `--pull-request-title-pattern` | `string` | Override the pull request title pattern. Defaults to `chore${scope}: release${component} ${version}` | | `--pull-request-header` | `string` | Override the pull request header. Defaults to `:robot: I have created a release *beep* *boop*` | | `--pull-request-footer` | `string` | Override the pull request footer. Defaults to `This PR was generated with Release Please. See documentation.` | -| `--extra-files` | `string[]` | Extra file paths for the release strategy to consider | +| `--extra-files` | `string[]` | Extra file paths for the release strategy to update | | `--version-file` | `string` | Ruby only. Path to the `version.rb` file | ## Creating/updating release PRs @@ -115,7 +115,7 @@ need to specify your release options: | `--pull-request-header` | `string` | Override the pull request header. Defaults to `:robot: I have created a release *beep* *boop*` | | `--pull-request-footer` | `string` | Override the pull request footer. Defaults to `This PR was generated with Release Please. See documentation.` | | `--signoff` | string | Add [`Signed-off-by`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff) line at the end of the commit log message using the user and email provided. (format "Name \") | -| `--extra-files` | `string[]` | Extra file paths for the release strategy to consider | +| `--extra-files` | `string[]` | Extra file paths for the release strategy to update | | `--version-file` | `string` | Ruby only. Path to the `version.rb` file | | `--skip-labeling` | `boolean` | If set, labels will not be applied to pull requests | | `--include-v-in-tags` | `boolean` | Include "v" in tag versions. Defaults to `true`. | diff --git a/src/bin/release-please.ts b/src/bin/release-please.ts index 4baf2c626..55ae2d6b2 100644 --- a/src/bin/release-please.ts +++ b/src/bin/release-please.ts @@ -282,7 +282,7 @@ function pullRequestStrategyOptions(yargs: yargs.Argv): yargs.Argv { type: 'string', }) .option('extra-files', { - describe: 'extra files for the strategy to consider', + describe: 'extra files for the strategy to update', type: 'string', coerce(arg?: string) { if (arg) { From 954623074dc7cb60a692b1713b778fa01b48ef0e Mon Sep 17 00:00:00 2001 From: Stan Tsouvallas Date: Thu, 8 May 2025 13:00:08 +1000 Subject: [PATCH 07/11] revert more unnecessary changes --- __snapshots__/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__snapshots__/cli.js b/__snapshots__/cli.js index e2e6a8361..696b90e27 100644 --- a/__snapshots__/cli.js +++ b/__snapshots__/cli.js @@ -193,7 +193,7 @@ Options: the first major release [boolean] [default: false] --prerelease-type type of the prerelease, e.g., alpha [string] - --extra-files extra files for the strategy to update + --extra-files extra files for the strategy to consider [string] --version-file path to version file to update, e.g., version.rb [string] From 31f71c83d372d0f539c73828cf9f99d786c74109 Mon Sep 17 00:00:00 2001 From: Stan Tsouvallas Date: Thu, 8 May 2025 13:00:38 +1000 Subject: [PATCH 08/11] move some stuff around --- schemas/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schemas/config.json b/schemas/config.json index bae6ea22e..dfd3aa240 100644 --- a/schemas/config.json +++ b/schemas/config.json @@ -493,7 +493,7 @@ "snapshot-label": true, "initial-version": true, "exclude-paths": true, - "additional-paths": true, - "component-no-space": false + "component-no-space": false, + "additional-paths": true } } From 9711142bc1f5f5262b5c437a20bc3ef546fc4ea5 Mon Sep 17 00:00:00 2001 From: Stan Tsouvallas Date: Thu, 8 May 2025 14:12:34 +1000 Subject: [PATCH 09/11] better handling of edge cases --- package.json | 2 +- src/util/commit-split.ts | 44 ++++++++++++++++++++++++++++++--------- test/util/commit-split.ts | 13 ++++++++++++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index de1619edd..abf1e63cd 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "./build/src/index.js", "bin": "./build/src/bin/release-please.js", "scripts": { - "test": "cross-env ENVIRONMENT=test LC_ALL=en c8 mocha --node-option no-experimental-fetch --recursive --timeout=5000 build/test", + "test": "cross-env ENVIRONMENT=test LC_ALL=en c8 mocha --recursive --timeout=5000 build/test", "docs": "echo add docs tests", "test:snap": "cross-env SNAPSHOT_UPDATE=1 LC_ALL=en npm test", "clean": "gts clean", diff --git a/src/util/commit-split.ts b/src/util/commit-split.ts index f9ab6581c..989f50f91 100644 --- a/src/util/commit-split.ts +++ b/src/util/commit-split.ts @@ -98,23 +98,47 @@ export class CommitSplit { // in this edge-case we should not attempt to update the path. if (splitPath.length === 1) continue; - let pkgName: string | undefined; + // first assign the file to the primary package. + // Each file can match at most one primary package name. + // These are sorted by longest path first, so the first + // match is the most specific. ie there are two packages ["core", "core/lib"] + // then the file "core/lib/foo.txt" should be assigned to "core/lib" and not "core". + let primaryPkgName; if (this.packagePaths) { // only track paths under this.packagePaths - pkgName = Object.entries(this.packagePaths).find( - ([path, additionalPaths]) => - file.indexOf(`${path}/`) === 0 || - additionalPaths.some(path => file.indexOf(`${path}/`) === 0) + primaryPkgName = Object.entries(this.packagePaths).find( + ([p]) => file.indexOf(`${p}/`) === 0 )?.[0]; } else { // track paths by top level folder - pkgName = splitPath[0]; + primaryPkgName = splitPath[0]; } - if (!pkgName || dedupe.has(pkgName)) continue; - else dedupe.add(pkgName); - if (!splitCommits[pkgName]) splitCommits[pkgName] = []; - splitCommits[pkgName].push(commit); + if (!primaryPkgName || dedupe.has(primaryPkgName)) continue; + else dedupe.add(primaryPkgName); + if (!splitCommits[primaryPkgName]) splitCommits[primaryPkgName] = []; + splitCommits[primaryPkgName].push(commit); } + + // next assign the file packages based on their additional paths. + // It's possible to have multiple packages match the same file here. + let additionalPkgNames: string[] = []; + commit.files.forEach(file => { + if (this.packagePaths) { + Object.entries(this.packagePaths).forEach( + ([pkgName, additionalPaths]) => { + if ( + additionalPaths.some(path => file.indexOf(`${path}/`) === 0) + ) { + if (dedupe.has(pkgName)) return; + additionalPkgNames.push(pkgName); + if (!splitCommits[pkgName]) splitCommits[pkgName] = []; + splitCommits[pkgName].push(commit); + } + } + ); + } + }); + if (commit.files.length === 0 && this.includeEmpty) { if (this.packagePaths) { for (const pkgName of Object.keys(this.packagePaths)) { diff --git a/test/util/commit-split.ts b/test/util/commit-split.ts index 99a531f76..656bcb483 100644 --- a/test/util/commit-split.ts +++ b/test/util/commit-split.ts @@ -123,4 +123,17 @@ describe('CommitSplit', () => { expect(splitCommits['pkg4']).to.be.undefined; }); }); + + describe('handles a commit which belongs to multiple components', () => { + it('should share commits', () => { + const commitSplit = new CommitSplit({ + includeEmpty: false, + // both pkg7 and pkg8 depend on pkg1 + packagePaths: {pkg7: ['pkg1'], pkg8: ['pkg1']}, + }); + const splitCommits = commitSplit.split(commits); + expect(splitCommits['pkg7']).lengthOf(2); + expect(splitCommits['pkg8']).lengthOf(2); + }); + }); }); From afc2571e09760813a962ecb252fd603afddef66a Mon Sep 17 00:00:00 2001 From: Stan Tsouvallas Date: Thu, 8 May 2025 14:20:35 +1000 Subject: [PATCH 10/11] cleanup --- package.json | 2 +- src/bin/release-please.ts | 2 +- src/util/commit-split.ts | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index abf1e63cd..de1619edd 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "./build/src/index.js", "bin": "./build/src/bin/release-please.js", "scripts": { - "test": "cross-env ENVIRONMENT=test LC_ALL=en c8 mocha --recursive --timeout=5000 build/test", + "test": "cross-env ENVIRONMENT=test LC_ALL=en c8 mocha --node-option no-experimental-fetch --recursive --timeout=5000 build/test", "docs": "echo add docs tests", "test:snap": "cross-env SNAPSHOT_UPDATE=1 LC_ALL=en npm test", "clean": "gts clean", diff --git a/src/bin/release-please.ts b/src/bin/release-please.ts index 5126e431e..39aa9cd42 100644 --- a/src/bin/release-please.ts +++ b/src/bin/release-please.ts @@ -283,7 +283,7 @@ function pullRequestStrategyOptions(yargs: yargs.Argv): yargs.Argv { type: 'string', }) .option('extra-files', { - describe: 'extra files for the strategy to update', + describe: 'extra files for the strategy to consider', type: 'string', coerce(arg?: string) { if (arg) { diff --git a/src/util/commit-split.ts b/src/util/commit-split.ts index 989f50f91..f2b278412 100644 --- a/src/util/commit-split.ts +++ b/src/util/commit-split.ts @@ -98,10 +98,10 @@ export class CommitSplit { // in this edge-case we should not attempt to update the path. if (splitPath.length === 1) continue; - // first assign the file to the primary package. - // Each file can match at most one primary package name. - // These are sorted by longest path first, so the first - // match is the most specific. ie there are two packages ["core", "core/lib"] + // first match the file to a primary package. + // Each file can match at most one primary package. + // Files are sorted by longest path first, so the first + // match will be the most specific. ie if there are two packages: ["core", "core/lib"] // then the file "core/lib/foo.txt" should be assigned to "core/lib" and not "core". let primaryPkgName; if (this.packagePaths) { @@ -119,8 +119,10 @@ export class CommitSplit { splitCommits[primaryPkgName].push(commit); } - // next assign the file packages based on their additional paths. - // It's possible to have multiple packages match the same file here. + // next assign the file to additional packages based on their additional paths. + // This is for cases where someone has specified dependencies outside of the + // package directory. For example, if both packages "foo" and "bar" have additional + // path "shared", then commits to "shared/foo.txt" should be assigned to both packages. let additionalPkgNames: string[] = []; commit.files.forEach(file => { if (this.packagePaths) { From 0bbc136edcb745c3ecd2bd0eb55dd15c2e8d59e2 Mon Sep 17 00:00:00 2001 From: Stan Tsouvallas Date: Fri, 9 May 2025 10:17:24 +1000 Subject: [PATCH 11/11] fix dedupe and remove unneccessary array --- src/util/commit-split.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/commit-split.ts b/src/util/commit-split.ts index f2b278412..8b24f9ea9 100644 --- a/src/util/commit-split.ts +++ b/src/util/commit-split.ts @@ -123,7 +123,6 @@ export class CommitSplit { // This is for cases where someone has specified dependencies outside of the // package directory. For example, if both packages "foo" and "bar" have additional // path "shared", then commits to "shared/foo.txt" should be assigned to both packages. - let additionalPkgNames: string[] = []; commit.files.forEach(file => { if (this.packagePaths) { Object.entries(this.packagePaths).forEach( @@ -132,7 +131,7 @@ export class CommitSplit { additionalPaths.some(path => file.indexOf(`${path}/`) === 0) ) { if (dedupe.has(pkgName)) return; - additionalPkgNames.push(pkgName); + dedupe.add(pkgName); if (!splitCommits[pkgName]) splitCommits[pkgName] = []; splitCommits[pkgName].push(commit); }