豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 39af989

Browse files
committed
feat(ng-dev): sort commits in release notes based on description
Commits within groups are currently sorted based on their commit type. If types match, commits are displayed in the order they have been extracted by `git log`. This is not ideal because f a custom categorization method is specified though, commits could incorporate an entry-point as prefix for commit descriptions. The commits should be predictively sorted alphabetically if the types match. This makes it easier to scroll through the release notes and find commits.
1 parent 862a274 commit 39af989

File tree

11 files changed

+60
-27
lines changed

11 files changed

+60
-27
lines changed

ng-dev/pr/merge/defaults/lts-branch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from '../../../release/versioning';
1919
import {promptConfirm, red, warn, yellow} from '../../../utils/console';
2020
import {InvalidTargetBranchError} from '../target-label';
21+
import {defaultLocale} from '../../../utils/locale';
2122

2223
/**
2324
* Asserts that the given branch corresponds to an active LTS version-branch that can receive
@@ -63,7 +64,7 @@ export async function assertActiveLtsBranch(
6364
// allow the merge as per our LTS guarantees. Can be forcibly overridden if desired.
6465
// See: https://angular.io/guide/releases#support-policy-and-schedule.
6566
if (today > ltsEndDate) {
66-
const ltsEndDateText = ltsEndDate.toLocaleDateString('en-US');
67+
const ltsEndDateText = ltsEndDate.toLocaleDateString(defaultLocale);
6768
warn(red(`Long-term support ended for v${version.major} on ${ltsEndDateText}.`));
6869
warn(
6970
yellow(

ng-dev/release/notes/context.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {COMMIT_TYPES, ReleaseNotesLevel} from '../../commit-message/config';
1010
import {CommitFromGitLog} from '../../commit-message/parse';
1111
import {GithubConfig} from '../../utils/config';
1212
import {ReleaseNotesConfig} from '../config/index';
13+
import {compareString} from '../../utils/locale';
1314

1415
/** List of types to be included in the release notes. */
1516
const typesToIncludeInReleaseNotes = Object.values(COMMIT_TYPES)
@@ -68,6 +69,19 @@ export class RenderContext {
6869
});
6970
}
7071

72+
/**
73+
* Comparator used for sorting commits within a release notes group. Commits
74+
* are sorted alphabetically based on their type. Commits having the same type
75+
* will be sorted alphabetically based on their determined description
76+
*/
77+
private _commitsWithinGroupComparator = (a: CategorizedCommit, b: CategorizedCommit): number => {
78+
const typeCompareOrder = compareString(a.type, b.type);
79+
if (typeCompareOrder === 0) {
80+
return compareString(a.description, b.description);
81+
}
82+
return typeCompareOrder;
83+
};
84+
7185
/**
7286
* Organizes and sorts the commits into groups of commits.
7387
*
@@ -94,9 +108,9 @@ export class RenderContext {
94108
const commitGroups = Array.from(groups.entries())
95109
.map(([title, commits]) => ({
96110
title,
97-
commits: commits.sort((a, b) => (a.type > b.type ? 1 : a.type < b.type ? -1 : 0)),
111+
commits: commits.sort(this._commitsWithinGroupComparator),
98112
}))
99-
.sort((a, b) => (a.title > b.title ? 1 : a.title < b.title ? -1 : 0));
113+
.sort((a, b) => compareString(a.title, b.title));
100114

101115
// If the configuration provides a sorting order, updated the sorted list of group keys to
102116
// satisfy the order of the groups provided in the list with any groups not found in the list at

ng-dev/release/publish/test/common.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ describe('common release action logic', () => {
132132
### test
133133
| Commit | Description |
134134
| -- | -- |
135-
| <..> | second commit |
136135
| <..> | first commit |
136+
| <..> | second commit |
137137
## Special Thanks
138138
`,
139139
);

ng-dev/release/publish/test/cut-lts-patch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ describe('cut an LTS patch action', () => {
108108
### pkg1
109109
| Commit | Type | Description |
110110
| -- | -- | -- |
111-
| <..> | feat | not yet released *2 |
112111
| <..> | feat | not yet released *1 |
112+
| <..> | feat | not yet released *2 |
113113
## Special Thanks
114114
`);
115115
});

ng-dev/release/publish/test/cut-new-patch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ describe('cut new patch action', () => {
8888
### pkg1
8989
| Commit | Type | Description |
9090
| -- | -- | -- |
91-
| <..> | feat | not yet released *2 |
9291
| <..> | feat | not yet released *1 |
92+
| <..> | feat | not yet released *2 |
9393
## Special Thanks
9494
`);
9595
});

ng-dev/release/publish/test/cut-next-prerelease.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ describe('cut next pre-release action', () => {
101101
| Commit | Type | Description |
102102
| -- | -- | -- |
103103
| <..> | feat | not released yet, but cherry-picked |
104-
| <..> | feat | only in next, not released yet *2 |
105104
| <..> | feat | only in next, not released yet *1 |
105+
| <..> | feat | only in next, not released yet *2 |
106106
## Special Thanks
107107
`);
108108
},
@@ -150,8 +150,8 @@ describe('cut next pre-release action', () => {
150150
### pkg1
151151
| Commit | Type | Description |
152152
| -- | -- | -- |
153-
| <..> | feat | not released yet *2 |
154153
| <..> | feat | not released yet *1 |
154+
| <..> | feat | not released yet *2 |
155155
## Special Thanks
156156
`);
157157
});
@@ -198,8 +198,8 @@ describe('cut next pre-release action', () => {
198198
### pkg1
199199
| Commit | Type | Description |
200200
| -- | -- | -- |
201-
| <..> | feat | not released yet *2 |
202201
| <..> | feat | not released yet *1 |
202+
| <..> | feat | not released yet *2 |
203203
## Special Thanks
204204
`);
205205
});

ng-dev/release/publish/test/cut-stable.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ describe('cut stable action', () => {
152152
### pkg1
153153
| Commit | Type | Description |
154154
| -- | -- | -- |
155-
| <..> | fix | not yet released *2 |
155+
| <..> | fix | landed in patch, not released but cherry-picked *1 |
156156
| <..> | fix | not yet released *1 |
157-
| <..> | fix | released release-candidate *2 |
158-
| <..> | fix | released release-candidate *1 |
159-
| <..> | fix | released feature-freeze pre-release *2 |
157+
| <..> | fix | not yet released *2 |
160158
| <..> | fix | released feature-freeze pre-release *1 |
161-
| <..> | fix | released first next pre-release *2 |
159+
| <..> | fix | released feature-freeze pre-release *2 |
162160
| <..> | fix | released first next pre-release *1 |
163-
| <..> | fix | landed in patch, not released but cherry-picked *1 |
161+
| <..> | fix | released first next pre-release *2 |
162+
| <..> | fix | released release-candidate *1 |
163+
| <..> | fix | released release-candidate *2 |
164164
## Special Thanks
165165
`);
166166
},

ng-dev/release/publish/test/move-next-into-feature-freeze.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ describe('move next into feature-freeze action', () => {
129129
| Commit | Type | Description |
130130
| -- | -- | -- |
131131
| <..> | feat | not released yet, but cherry-picked |
132-
| <..> | feat | only in next, not released yet *2 |
133132
| <..> | feat | only in next, not released yet *1 |
133+
| <..> | feat | only in next, not released yet *2 |
134134
`);
135135
},
136136
);

ng-dev/release/publish/test/move-next-into-release-candidate.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ describe('move next into release-candidate action', () => {
112112
| Commit | Type | Description |
113113
| -- | -- | -- |
114114
| <..> | feat | not released yet, but cherry-picked |
115-
| <..> | feat | only in next, not released yet *2 |
116115
| <..> | feat | only in next, not released yet *1 |
116+
| <..> | feat | only in next, not released yet *2 |
117117
`);
118118
},
119119
);

ng-dev/release/publish/test/release-notes/generation.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ describe('release notes generation', () => {
5454
### @angular-devkit/core
5555
| Commit | Type | Description |
5656
| -- | -- | -- |
57-
| <..> | fix | commit *2 |
5857
| <..> | fix | commit *1 |
58+
| <..> | fix | commit *2 |
5959
### @angular-devkit/test
6060
| Commit | Type | Description |
6161
| -- | -- | -- |
62-
| <..> | fix | commit *4 |
6362
| <..> | fix | commit *3 |
63+
| <..> | fix | commit *4 |
6464
## Special Thanks
6565
`);
6666
});
@@ -85,13 +85,13 @@ describe('release notes generation', () => {
8585
### cdk
8686
| Commit | Type | Description |
8787
| -- | -- | -- |
88-
| <..> | fix | commit *2 |
8988
| <..> | fix | commit *1 |
89+
| <..> | fix | commit *2 |
9090
### material
9191
| Commit | Type | Description |
9292
| -- | -- | -- |
93-
| <..> | fix | commit *4 |
9493
| <..> | fix | commit *3 |
94+
| <..> | fix | commit *4 |
9595
## Special Thanks
9696
`);
9797
});
@@ -158,8 +158,8 @@ describe('release notes generation', () => {
158158
### cdk
159159
| Commit | Type | Description |
160160
| -- | -- | -- |
161-
| <..> | fix | platform: fix detection of chromium |
162161
| <..> | fix | a11y: fix module definition |
162+
| <..> | fix | platform: fix detection of chromium |
163163
### material
164164
| Commit | Type | Description |
165165
| -- | -- | -- |
@@ -257,13 +257,13 @@ describe('release notes generation', () => {
257257
### @angular-devkit/core
258258
| Commit | Description |
259259
| -- | -- |
260-
| <..> | commit *2 |
261260
| <..> | commit *1 |
261+
| <..> | commit *2 |
262262
### @angular-devkit/test
263263
| Commit | Description |
264264
| -- | -- |
265-
| <..> | commit *4 |
266265
| <..> | commit *3 |
266+
| <..> | commit *4 |
267267
## Special Thanks
268268
`);
269269
});
@@ -288,13 +288,13 @@ describe('release notes generation', () => {
288288
### cdk
289289
| Commit | Description |
290290
| -- | -- |
291-
| <..> | commit *2 |
292291
| <..> | commit *1 |
292+
| <..> | commit *2 |
293293
### material
294294
| Commit | Description |
295295
| -- | -- |
296-
| <..> | commit *4 |
297296
| <..> | commit *3 |
297+
| <..> | commit *4 |
298298
## Special Thanks
299299
`);
300300
});
@@ -361,8 +361,8 @@ describe('release notes generation', () => {
361361
### cdk
362362
| Commit | Description |
363363
| -- | -- |
364-
| <..> | platform: fix detection of chromium |
365364
| <..> | a11y: fix module definition |
365+
| <..> | platform: fix detection of chromium |
366366
### material
367367
| Commit | Description |
368368
| -- | -- |

0 commit comments

Comments
 (0)