release-please 13.16.2 → 13.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/build/src/factories/plugin-factory.d.ts +1 -0
- package/build/src/manifest.js +41 -21
- package/build/src/plugins/cargo-workspace.d.ts +1 -0
- package/build/src/plugins/cargo-workspace.js +3 -0
- package/build/src/plugins/node-workspace.d.ts +1 -0
- package/build/src/plugins/node-workspace.js +3 -0
- package/build/src/plugins/workspace.d.ts +8 -0
- package/build/src/plugins/workspace.js +21 -2
- package/build/src/strategies/base.d.ts +1 -1
- package/build/src/strategy.d.ts +6 -0
- package/build/src/util/commit-split.d.ts +15 -0
- package/build/src/util/commit-split.js +25 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,45 @@
|
|
|
4
4
|
|
|
5
5
|
[1]: https://www.npmjs.com/package/release-please?activeTab=versions
|
|
6
6
|
|
|
7
|
+
### [13.16.5](https://github.com/googleapis/release-please/compare/v13.16.4...v13.16.5) (2022-05-18)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* all release tag matching if includeComponentInTag is false ([#1442](https://github.com/googleapis/release-please/issues/1442)) ([82a7c71](https://github.com/googleapis/release-please/commit/82a7c7186cf7c30530ce179b42b439400c539b52))
|
|
13
|
+
|
|
14
|
+
### [13.16.4](https://github.com/googleapis/release-please/compare/v13.16.3...v13.16.4) (2022-05-17)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add release labels if release PR was completed ([#1433](https://github.com/googleapis/release-please/issues/1433)) ([072498c](https://github.com/googleapis/release-please/commit/072498c8ce2f89bc86eb33445d87491e3ab31fbd))
|
|
20
|
+
* CommitSplit with includeEmpty should add commit to all packages ([#1432](https://github.com/googleapis/release-please/issues/1432)) ([19629cb](https://github.com/googleapis/release-please/commit/19629cb42da625d6c62e67f1e9edf7f3cf14d6ee)), closes [#1360](https://github.com/googleapis/release-please/issues/1360)
|
|
21
|
+
* Manifest.fromConfig should find branch component ([#1436](https://github.com/googleapis/release-please/issues/1436)) ([628a562](https://github.com/googleapis/release-please/commit/628a562a21245ed02546aa0c40c97a0e3d50a0c7))
|
|
22
|
+
|
|
23
|
+
### [13.16.3](https://github.com/googleapis/release-please/compare/v13.16.2...v13.16.3) (2022-05-17)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* add release labels if release PR was completed ([#1433](https://github.com/googleapis/release-please/issues/1433)) ([072498c](https://github.com/googleapis/release-please/commit/072498c8ce2f89bc86eb33445d87491e3ab31fbd))
|
|
29
|
+
* CommitSplit with includeEmpty should add commit to all packages ([#1432](https://github.com/googleapis/release-please/issues/1432)) ([19629cb](https://github.com/googleapis/release-please/commit/19629cb42da625d6c62e67f1e9edf7f3cf14d6ee)), closes [#1360](https://github.com/googleapis/release-please/issues/1360)
|
|
30
|
+
* workspace plugins should update manifest versions ([#1429](https://github.com/googleapis/release-please/issues/1429)) ([ab802a9](https://github.com/googleapis/release-please/commit/ab802a924704044b26017b40a2da48657022faad))
|
|
31
|
+
|
|
32
|
+
### [13.16.3](https://github.com/googleapis/release-please/compare/v13.16.2...v13.16.3) (2022-05-13)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* workspace plugins should update manifest versions ([#1429](https://github.com/googleapis/release-please/issues/1429)) ([ab802a9](https://github.com/googleapis/release-please/commit/ab802a924704044b26017b40a2da48657022faad))
|
|
38
|
+
|
|
39
|
+
### [13.16.3](https://github.com/googleapis/release-please/compare/v13.16.2...v13.16.3) (2022-05-13)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* workspace plugins should update manifest versions ([#1429](https://github.com/googleapis/release-please/issues/1429)) ([ab802a9](https://github.com/googleapis/release-please/commit/ab802a924704044b26017b40a2da48657022faad))
|
|
45
|
+
|
|
7
46
|
### [13.16.2](https://github.com/googleapis/release-please/compare/v13.16.1...v13.16.2) (2022-05-12)
|
|
8
47
|
|
|
9
48
|
|
package/build/src/manifest.js
CHANGED
|
@@ -145,9 +145,9 @@ class Manifest {
|
|
|
145
145
|
github,
|
|
146
146
|
...config,
|
|
147
147
|
});
|
|
148
|
-
const component = await strategy.
|
|
148
|
+
const component = await strategy.getBranchComponent();
|
|
149
149
|
const releasedVersions = {};
|
|
150
|
-
const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version), config
|
|
150
|
+
const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version), config, component);
|
|
151
151
|
if (latestVersion) {
|
|
152
152
|
releasedVersions[path] = latestVersion;
|
|
153
153
|
}
|
|
@@ -314,6 +314,7 @@ class Manifest {
|
|
|
314
314
|
github: this.github,
|
|
315
315
|
targetBranch: this.targetBranch,
|
|
316
316
|
repositoryConfig: this.repositoryConfig,
|
|
317
|
+
manifestPath: this.manifestPath,
|
|
317
318
|
}));
|
|
318
319
|
let strategies = strategiesByPath;
|
|
319
320
|
for (const plugin of plugins) {
|
|
@@ -603,20 +604,16 @@ class Manifest {
|
|
|
603
604
|
}
|
|
604
605
|
}
|
|
605
606
|
async createReleasesForPullRequest(releases, pullRequest) {
|
|
606
|
-
|
|
607
|
-
const promises = [];
|
|
608
|
-
for (const release of releases) {
|
|
609
|
-
promises.push(this.createRelease(release));
|
|
610
|
-
}
|
|
607
|
+
logger_1.logger.info(`Creating ${releases.length} releases for pull #${pullRequest.number}`);
|
|
611
608
|
const duplicateReleases = [];
|
|
612
609
|
const githubReleases = [];
|
|
613
|
-
for (const
|
|
610
|
+
for (const release of releases) {
|
|
614
611
|
try {
|
|
615
|
-
githubReleases.push(await
|
|
612
|
+
githubReleases.push(await this.createRelease(release));
|
|
616
613
|
}
|
|
617
614
|
catch (err) {
|
|
618
615
|
if (err instanceof errors_1.DuplicateReleaseError) {
|
|
619
|
-
logger_1.logger.warn(`Duplicate release tag: ${
|
|
616
|
+
logger_1.logger.warn(`Duplicate release tag: ${release.tag.toString()}`);
|
|
620
617
|
duplicateReleases.push(err);
|
|
621
618
|
}
|
|
622
619
|
else {
|
|
@@ -624,14 +621,28 @@ class Manifest {
|
|
|
624
621
|
}
|
|
625
622
|
}
|
|
626
623
|
}
|
|
627
|
-
if (duplicateReleases.length > 0
|
|
628
|
-
|
|
624
|
+
if (duplicateReleases.length > 0) {
|
|
625
|
+
if (duplicateReleases.length + githubReleases.length ===
|
|
626
|
+
releases.length) {
|
|
627
|
+
// we've either tagged all releases or they were duplicates:
|
|
628
|
+
// adjust tags on pullRequest
|
|
629
|
+
await Promise.all([
|
|
630
|
+
this.github.removeIssueLabels(this.labels, pullRequest.number),
|
|
631
|
+
this.github.addIssueLabels(this.releaseLabels, pullRequest.number),
|
|
632
|
+
]);
|
|
633
|
+
}
|
|
634
|
+
if (githubReleases.length === 0) {
|
|
635
|
+
// If all releases were duplicate, throw a duplicate error
|
|
636
|
+
throw duplicateReleases[0];
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
// adjust tags on pullRequest
|
|
641
|
+
await Promise.all([
|
|
642
|
+
this.github.removeIssueLabels(this.labels, pullRequest.number),
|
|
643
|
+
this.github.addIssueLabels(this.releaseLabels, pullRequest.number),
|
|
644
|
+
]);
|
|
629
645
|
}
|
|
630
|
-
// adjust tags on pullRequest
|
|
631
|
-
await Promise.all([
|
|
632
|
-
this.github.removeIssueLabels(this.labels, pullRequest.number),
|
|
633
|
-
this.github.addIssueLabels(this.releaseLabels, pullRequest.number),
|
|
634
|
-
]);
|
|
635
646
|
return githubReleases;
|
|
636
647
|
}
|
|
637
648
|
async createRelease(release) {
|
|
@@ -829,7 +840,7 @@ function isPublishedVersion(strategy, version) {
|
|
|
829
840
|
* @param {string} prefix Limit the release to a specific component.
|
|
830
841
|
* @param pullRequestTitlePattern Configured PR title pattern.
|
|
831
842
|
*/
|
|
832
|
-
async function latestReleaseVersion(github, targetBranch, releaseFilter,
|
|
843
|
+
async function latestReleaseVersion(github, targetBranch, releaseFilter, config, prefix) {
|
|
833
844
|
const branchPrefix = prefix
|
|
834
845
|
? prefix.endsWith('-')
|
|
835
846
|
? prefix.replace(/-$/, '')
|
|
@@ -859,7 +870,7 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, prefix,
|
|
|
859
870
|
if (branchName.getComponent() !== branchPrefix) {
|
|
860
871
|
continue;
|
|
861
872
|
}
|
|
862
|
-
const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, pullRequestTitlePattern);
|
|
873
|
+
const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, config.pullRequestTitlePattern);
|
|
863
874
|
if (!pullRequestTitle) {
|
|
864
875
|
continue;
|
|
865
876
|
}
|
|
@@ -878,7 +889,7 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, prefix,
|
|
|
878
889
|
if (!tagName) {
|
|
879
890
|
continue;
|
|
880
891
|
}
|
|
881
|
-
if (tagName
|
|
892
|
+
if (tagMatchesConfig(tagName, branchPrefix, config.includeComponentInTag)) {
|
|
882
893
|
logger_1.logger.debug(`found release for ${prefix}`, tagName.version);
|
|
883
894
|
if (!commitShas.has(release.sha)) {
|
|
884
895
|
logger_1.logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
|
|
@@ -901,7 +912,7 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, prefix,
|
|
|
901
912
|
if (!tagName) {
|
|
902
913
|
continue;
|
|
903
914
|
}
|
|
904
|
-
if (tagName
|
|
915
|
+
if (tagMatchesConfig(tagName, branchPrefix, config.includeComponentInTag)) {
|
|
905
916
|
if (!commitShas.has(tag.sha)) {
|
|
906
917
|
logger_1.logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
|
|
907
918
|
continue;
|
|
@@ -961,4 +972,13 @@ function commitsAfterSha(commits, lastReleaseSha) {
|
|
|
961
972
|
}
|
|
962
973
|
return commits.slice(0, index);
|
|
963
974
|
}
|
|
975
|
+
/**
|
|
976
|
+
* Returns true if the release tag matches the configured component. Returns
|
|
977
|
+
* true if `includeComponentInTag` is false and there is no component in the
|
|
978
|
+
* tag, OR if the tag's component matches the release component.
|
|
979
|
+
*/
|
|
980
|
+
function tagMatchesConfig(tag, branchComponent, includeComponentInTag) {
|
|
981
|
+
return ((includeComponentInTag && tag.component === branchComponent) ||
|
|
982
|
+
(!includeComponentInTag && !tag.component));
|
|
983
|
+
}
|
|
964
984
|
//# sourceMappingURL=manifest.js.map
|
|
@@ -47,5 +47,6 @@ export declare class CargoWorkspace extends WorkspacePlugin<CrateInfo> {
|
|
|
47
47
|
protected buildGraph(allPackages: CrateInfo[]): Promise<DependencyGraph<CrateInfo>>;
|
|
48
48
|
protected inScope(candidate: CandidateReleasePullRequest): boolean;
|
|
49
49
|
protected packageNameFromPackage(pkg: CrateInfo): string;
|
|
50
|
+
protected pathFromPackage(pkg: CrateInfo): string;
|
|
50
51
|
}
|
|
51
52
|
export {};
|
|
@@ -213,6 +213,9 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
213
213
|
packageNameFromPackage(pkg) {
|
|
214
214
|
return pkg.name;
|
|
215
215
|
}
|
|
216
|
+
pathFromPackage(pkg) {
|
|
217
|
+
return pkg.path;
|
|
218
|
+
}
|
|
216
219
|
}
|
|
217
220
|
exports.CargoWorkspace = CargoWorkspace;
|
|
218
221
|
function getChangelogDepsNotes(originalManifest, updatedManifest) {
|
|
@@ -33,5 +33,6 @@ export declare class NodeWorkspace extends WorkspacePlugin<Package> {
|
|
|
33
33
|
protected buildGraph(allPackages: Package[]): Promise<DependencyGraph<Package>>;
|
|
34
34
|
protected inScope(candidate: CandidateReleasePullRequest): boolean;
|
|
35
35
|
protected packageNameFromPackage(pkg: Package): string;
|
|
36
|
+
protected pathFromPackage(pkg: Package): string;
|
|
36
37
|
}
|
|
37
38
|
export {};
|
|
@@ -235,6 +235,9 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
235
235
|
packageNameFromPackage(pkg) {
|
|
236
236
|
return pkg.name;
|
|
237
237
|
}
|
|
238
|
+
pathFromPackage(pkg) {
|
|
239
|
+
return pkg.location;
|
|
240
|
+
}
|
|
238
241
|
}
|
|
239
242
|
exports.NodeWorkspace = NodeWorkspace;
|
|
240
243
|
function getChangelogDepsNotes(original, updated) {
|
|
@@ -8,6 +8,7 @@ export interface DependencyNode<T> {
|
|
|
8
8
|
value: T;
|
|
9
9
|
}
|
|
10
10
|
export interface WorkspacePluginOptions {
|
|
11
|
+
manifestPath?: string;
|
|
11
12
|
updateAllPackages?: boolean;
|
|
12
13
|
}
|
|
13
14
|
interface AllPackages<T> {
|
|
@@ -27,6 +28,7 @@ interface AllPackages<T> {
|
|
|
27
28
|
*/
|
|
28
29
|
export declare abstract class WorkspacePlugin<T> extends ManifestPlugin {
|
|
29
30
|
private updateAllPackages;
|
|
31
|
+
private manifestPath;
|
|
30
32
|
constructor(github: GitHub, targetBranch: string, repositoryConfig: RepositoryConfig, options?: WorkspacePluginOptions);
|
|
31
33
|
run(candidates: CandidateReleasePullRequest[]): Promise<CandidateReleasePullRequest[]>;
|
|
32
34
|
/**
|
|
@@ -83,6 +85,12 @@ export declare abstract class WorkspacePlugin<T> extends ManifestPlugin {
|
|
|
83
85
|
* @returns {string} The package name.
|
|
84
86
|
*/
|
|
85
87
|
protected abstract packageNameFromPackage(pkg: T): string;
|
|
88
|
+
/**
|
|
89
|
+
* Given a package, return the path in the repo to the package.
|
|
90
|
+
* @param {T} pkg The package definition.
|
|
91
|
+
* @returns {string} The package path.
|
|
92
|
+
*/
|
|
93
|
+
protected abstract pathFromPackage(pkg: T): string;
|
|
86
94
|
/**
|
|
87
95
|
* Amend any or all in-scope candidates once all other processing has occured.
|
|
88
96
|
*
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.WorkspacePlugin = void 0;
|
|
17
17
|
const plugin_1 = require("../plugin");
|
|
18
|
+
const manifest_1 = require("../manifest");
|
|
18
19
|
const logger_1 = require("../util/logger");
|
|
19
20
|
const merge_1 = require("./merge");
|
|
21
|
+
const release_please_manifest_1 = require("../updaters/release-please-manifest");
|
|
20
22
|
/**
|
|
21
23
|
* The plugin generalizes the logic for handling a workspace and
|
|
22
24
|
* will bump dependencies of managed packages if those dependencies
|
|
@@ -30,9 +32,10 @@ const merge_1 = require("./merge");
|
|
|
30
32
|
*/
|
|
31
33
|
class WorkspacePlugin extends plugin_1.ManifestPlugin {
|
|
32
34
|
constructor(github, targetBranch, repositoryConfig, options = {}) {
|
|
33
|
-
var _a;
|
|
35
|
+
var _a, _b;
|
|
34
36
|
super(github, targetBranch, repositoryConfig);
|
|
35
|
-
this.
|
|
37
|
+
this.manifestPath = (_a = options.manifestPath) !== null && _a !== void 0 ? _a : manifest_1.DEFAULT_RELEASE_PLEASE_MANIFEST;
|
|
38
|
+
this.updateAllPackages = (_b = options.updateAllPackages) !== null && _b !== void 0 ? _b : false;
|
|
36
39
|
}
|
|
37
40
|
async run(candidates) {
|
|
38
41
|
logger_1.logger.info('Running workspace plugin');
|
|
@@ -63,6 +66,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
|
|
|
63
66
|
const orderedPackages = this.buildGraphOrder(graph, packageNamesToUpdate);
|
|
64
67
|
logger_1.logger.info(`Updating ${orderedPackages.length} packages`);
|
|
65
68
|
const updatedVersions = new Map();
|
|
69
|
+
const updatedPathVersions = new Map();
|
|
66
70
|
for (const pkg of orderedPackages) {
|
|
67
71
|
const packageName = this.packageNameFromPackage(pkg);
|
|
68
72
|
logger_1.logger.debug(`package: ${packageName}`);
|
|
@@ -76,6 +80,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
|
|
|
76
80
|
const version = this.bumpVersion(pkg);
|
|
77
81
|
logger_1.logger.debug(`version: ${version} forced bump`);
|
|
78
82
|
updatedVersions.set(packageName, version);
|
|
83
|
+
updatedPathVersions.set(this.pathFromPackage(pkg), version);
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
let newCandidates = [];
|
|
@@ -98,6 +103,20 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
|
|
|
98
103
|
logger_1.logger.info(`Merging ${newCandidates.length} in-scope candidates`);
|
|
99
104
|
const mergePlugin = new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig);
|
|
100
105
|
newCandidates = await mergePlugin.run(newCandidates);
|
|
106
|
+
if (newCandidates.length === 1) {
|
|
107
|
+
const newUpdates = newCandidates[0].pullRequest.updates;
|
|
108
|
+
newUpdates.push({
|
|
109
|
+
path: this.manifestPath,
|
|
110
|
+
createIfMissing: false,
|
|
111
|
+
updater: new release_please_manifest_1.ReleasePleaseManifest({
|
|
112
|
+
version: newCandidates[0].pullRequest.version,
|
|
113
|
+
versionsMap: updatedPathVersions,
|
|
114
|
+
}),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
logger_1.logger.warn(`Expected 1 merged candidate, got ${newCandidates.length}`);
|
|
119
|
+
}
|
|
101
120
|
logger_1.logger.info(`Post-processing ${newCandidates.length} in-scope candidates`);
|
|
102
121
|
newCandidates = this.postProcessCandidates(newCandidates, updatedVersions);
|
|
103
122
|
return [...outOfScopeCandidates, ...newCandidates];
|
|
@@ -79,7 +79,7 @@ export declare abstract class BaseStrategy implements Strategy {
|
|
|
79
79
|
*/
|
|
80
80
|
getComponent(): Promise<string | undefined>;
|
|
81
81
|
getDefaultComponent(): Promise<string | undefined>;
|
|
82
|
-
|
|
82
|
+
getBranchComponent(): Promise<string | undefined>;
|
|
83
83
|
getPackageName(): Promise<string | undefined>;
|
|
84
84
|
getDefaultPackageName(): Promise<string | undefined>;
|
|
85
85
|
protected normalizeComponent(component: string | undefined): string;
|
package/build/src/strategy.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ export interface Strategy {
|
|
|
36
36
|
* @returns {string}
|
|
37
37
|
*/
|
|
38
38
|
getComponent(): Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Return the component for this strategy used in the branch name.
|
|
41
|
+
* This may be a computed field.
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
getBranchComponent(): Promise<string | undefined>;
|
|
39
45
|
/**
|
|
40
46
|
* Validate whether version is a valid release.
|
|
41
47
|
* @param version Released version.
|
|
@@ -3,9 +3,24 @@ export interface CommitSplitOptions {
|
|
|
3
3
|
includeEmpty?: boolean;
|
|
4
4
|
packagePaths?: string[];
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Helper class for splitting commits by component path. If `packagePaths`
|
|
8
|
+
* is configured, then only consider the provided paths. If `includeEmpty`
|
|
9
|
+
* is configured, then commits without any touched files apply to all
|
|
10
|
+
* configured component paths.
|
|
11
|
+
*/
|
|
6
12
|
export declare class CommitSplit {
|
|
7
13
|
includeEmpty: boolean;
|
|
8
14
|
packagePaths?: string[];
|
|
9
15
|
constructor(opts?: CommitSplitOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Split commits by component path. If the commit splitter is configured
|
|
18
|
+
* with a set of tracked package paths, then only consider paths for
|
|
19
|
+
* configured components. If `includeEmpty` is configured, then a commit
|
|
20
|
+
* that does not touch any files will be applied to all components'
|
|
21
|
+
* commits.
|
|
22
|
+
* @param {Commit[]} commits The commits to split
|
|
23
|
+
* @returns {Record<string, Commit[]>} Commits indexed by component path
|
|
24
|
+
*/
|
|
10
25
|
split<T extends Commit>(commits: T[]): Record<string, T[]>;
|
|
11
26
|
}
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.CommitSplit = void 0;
|
|
17
17
|
const manifest_1 = require("../manifest");
|
|
18
|
+
/**
|
|
19
|
+
* Helper class for splitting commits by component path. If `packagePaths`
|
|
20
|
+
* is configured, then only consider the provided paths. If `includeEmpty`
|
|
21
|
+
* is configured, then commits without any touched files apply to all
|
|
22
|
+
* configured component paths.
|
|
23
|
+
*/
|
|
18
24
|
class CommitSplit {
|
|
19
25
|
constructor(opts) {
|
|
20
26
|
opts = opts || {};
|
|
@@ -50,7 +56,15 @@ class CommitSplit {
|
|
|
50
56
|
this.packagePaths = paths;
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Split commits by component path. If the commit splitter is configured
|
|
61
|
+
* with a set of tracked package paths, then only consider paths for
|
|
62
|
+
* configured components. If `includeEmpty` is configured, then a commit
|
|
63
|
+
* that does not touch any files will be applied to all components'
|
|
64
|
+
* commits.
|
|
65
|
+
* @param {Commit[]} commits The commits to split
|
|
66
|
+
* @returns {Record<string, Commit[]>} Commits indexed by component path
|
|
67
|
+
*/
|
|
54
68
|
split(commits) {
|
|
55
69
|
const splitCommits = {};
|
|
56
70
|
commits.forEach(commit => {
|
|
@@ -85,8 +99,16 @@ class CommitSplit {
|
|
|
85
99
|
splitCommits[pkgName].push(commit);
|
|
86
100
|
}
|
|
87
101
|
if (commit.files.length === 0 && this.includeEmpty) {
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
if (this.packagePaths) {
|
|
103
|
+
for (const pkgName of this.packagePaths) {
|
|
104
|
+
splitCommits[pkgName] = splitCommits[pkgName] || [];
|
|
105
|
+
splitCommits[pkgName].push(commit);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
for (const pkgName in splitCommits) {
|
|
110
|
+
splitCommits[pkgName].push(commit);
|
|
111
|
+
}
|
|
90
112
|
}
|
|
91
113
|
}
|
|
92
114
|
});
|
package/package.json
CHANGED