Skip to content

Commit d5c1756

Browse files
authored
Merge pull request microsoft#1323 from lahuey/master
[rush-lib] Add ability to opt out of changelog files for version policies.
2 parents c597521 + e522af3 commit d5c1756

7 files changed

Lines changed: 41 additions & 1 deletion

File tree

apps/rush-lib/assets/rush-init/common/config/rush/version-policies.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,16 @@
7777
* inappropriately. The minor/patch version parts will be bumped independently according
7878
* to the types of changes made to each project, according to the "rush change" command.
7979
*/
80-
"lockedMajor": 3
80+
"lockedMajor": 3,
81+
82+
/**
83+
* (Optional) When publishing is managed by Rush, by default the "rush change" command will
84+
* request changes for any projects that are modified by a pull request. These change entries
85+
* will produce a CHANGELOG.md file. If you author your CHANGELOG.md manually or announce updates
86+
* in some other way, set "exemptFromRushChange" to true to tell "rush change" to ignore the projects
87+
* belonging to this version policy.
88+
*/
89+
"exemptFromRushChange": false
8190
}
8291
/*[END "DEMO"]*/
8392
]

apps/rush-lib/src/api/VersionPolicy.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export enum VersionPolicyDefinitionName {
5252
export abstract class VersionPolicy {
5353
private _policyName: string;
5454
private _definitionName: VersionPolicyDefinitionName;
55+
private _exemptFromRushChange: boolean;
5556
private _versionFormatForCommit: VersionFormatForCommit;
5657
private _versionFormatForPublish: VersionFormatForPublish;
5758

@@ -80,6 +81,7 @@ export abstract class VersionPolicy {
8081
constructor(versionPolicyJson: IVersionPolicyJson) {
8182
this._policyName = versionPolicyJson.policyName;
8283
this._definitionName = VersionPolicyDefinitionName[versionPolicyJson.definitionName];
84+
this._exemptFromRushChange = versionPolicyJson.exemptFromRushChange || false;
8385

8486
const jsonDependencies: IVersionPolicyDependencyJson = versionPolicyJson.dependencies || { };
8587
this._versionFormatForCommit = jsonDependencies.versionFormatForCommit || VersionFormatForCommit.original;
@@ -107,6 +109,13 @@ export abstract class VersionPolicy {
107109
return this.definitionName === VersionPolicyDefinitionName.lockStepVersion;
108110
}
109111

112+
/**
113+
* Determines if a version policy wants to opt out of changelog files.
114+
*/
115+
public get exemptFromRushChange(): boolean {
116+
return this._exemptFromRushChange;
117+
}
118+
110119
/**
111120
* Returns an updated package json that satisfies the policy.
112121
*

apps/rush-lib/src/api/VersionPolicyConfiguration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface IVersionPolicyJson {
1414
policyName: string;
1515
definitionName: string;
1616
dependencies?: IVersionPolicyDependencyJson;
17+
exemptFromRushChange?: boolean;
1718
}
1819

1920
/**

apps/rush-lib/src/cli/actions/ChangeAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export class ChangeAction extends BaseRushAction {
173173

174174
this.rushConfiguration.projects
175175
.filter(project => project.shouldPublish)
176+
.filter(project => !project.versionPolicy || !project.versionPolicy.exemptFromRushChange)
176177
.filter(project => this._hasProjectChanged(changedFolders, project))
177178
.forEach(project => {
178179
const hostName: string | undefined = this._projectHostMap.get(project.packageName);

apps/rush-lib/src/schemas/version-policies.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
"mainProject": {
8484
"description": "The main project for this version policy",
8585
"type": "string"
86+
},
87+
"exemptFromRushChange": {
88+
"description": "If true, the version policy will not require changelog files.",
89+
"type": "boolean"
8690
}
8791
},
8892
"required": ["policyName", "definitionName", "version", "nextBump"],
@@ -105,6 +109,10 @@
105109
"lockedMajor": {
106110
"description": "The locked major version",
107111
"type": "number"
112+
},
113+
"exemptFromRushChange": {
114+
"description": "If true, the version policy will not require changelog files.",
115+
"type": "boolean"
108116
}
109117
},
110118
"required": ["policyName", "definitionName"],
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "Add ability to opt out of changelog files for version policies.",
5+
"packageName": "@microsoft/rush",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush",
10+
"email": "lahuey@users.noreply.github.com"
11+
}

common/reviews/api/rush-lib.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ export abstract class VersionPolicy {
331331
abstract bump(bumpType?: BumpType, identifier?: string): void;
332332
readonly definitionName: VersionPolicyDefinitionName;
333333
abstract ensure(project: IPackageJson, force?: boolean): IPackageJson | undefined;
334+
readonly exemptFromRushChange: boolean;
334335
readonly isLockstepped: boolean;
335336
// @internal
336337
abstract readonly _json: IVersionPolicyJson;

0 commit comments

Comments
 (0)