Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
878 changes: 441 additions & 437 deletions .github/local-actions/branch-manager/main.js

Large diffs are not rendered by default.

838 changes: 421 additions & 417 deletions github-actions/pull-request-labeling/main.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion ng-dev/commit-message/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ts_project(
"//ng-dev:__subpackages__",
],
deps = [
"//ng-dev:node_modules/@types/conventional-commits-parser",
"//ng-dev:node_modules/@types/git-raw-commits",
"//ng-dev:node_modules/@types/node",
"//ng-dev:node_modules/@types/yargs",
Expand Down
50 changes: 30 additions & 20 deletions ng-dev/commit-message/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Commit as ParsedCommit, Options, sync as parse} from 'conventional-commits-parser';
import {
CommitReference,
CommitNote,
ParserOptions,
CommitParser,
} from 'conventional-commits-parser';

/** A parsed commit, containing the information needed to validate the commit. */
export interface Commit {
Expand All @@ -19,17 +24,17 @@ export interface Commit {
/** The footer of the commit, containing issue references and note sections. */
footer: string;
/** A list of the references to other issues made throughout the commit message. */
references: ParsedCommit.Reference[];
references: CommitReference[];
/** The type of the commit message. */
type: string;
/** The scope of the commit message. */
scope: string;
/** The subject of the commit message. */
subject: string;
/** A list of breaking change notes in the commit message. */
breakingChanges: ParsedCommit.Note[];
breakingChanges: CommitNote[];
/** A list of deprecation notes in the commit message. */
deprecations: ParsedCommit.Note[];
deprecations: CommitNote[];
/** Whether the commit is a fixup commit. */
isFixup: boolean;
/** Whether the commit is a squash commit. */
Expand Down Expand Up @@ -101,18 +106,17 @@ const headerPattern = /^(\w+)(?:\(([^)]+)\))?: (.*)$/;
const headerCorrespondence = ['type', 'scope', 'subject'];
/**
* Configuration options for the commit parser.
*
* NOTE: An extended type from `Options` must be used because the current
* @types/conventional-commits-parser version does not include the `notesPattern` field.
*/
const parseOptions: Options & {notesPattern: (keywords: string) => RegExp} = {
const parseOptions: ParserOptions = {
commentChar: '#',
headerPattern,
headerCorrespondence,
noteKeywords: [NoteSections.BREAKING_CHANGE, NoteSections.DEPRECATED],
notesPattern: (keywords: string) => new RegExp(`^\\s*(${keywords}): ?(.*)`),
};

let commitParser: CommitParser | undefined;

/** Parse a commit message into its composite parts. */
export const parseCommitMessage: (fullText: string) => Commit = parseInternal;

Expand All @@ -130,21 +134,27 @@ function parseInternal(fullText: string | Buffer): CommitFromGitLog | Commit {
.replace(FIXUP_PREFIX_RE, '')
.replace(SQUASH_PREFIX_RE, '')
.replace(REVERT_PREFIX_RE, '');

commitParser ??= new CommitParser(parseOptions);

/** The initially parsed commit. */
const commit = parse(strippedCommitMsg, parseOptions);
const commit = commitParser.parse(strippedCommitMsg);
/** A list of breaking change notes from the commit. */
const breakingChanges: ParsedCommit.Note[] = [];
const breakingChanges: CommitNote[] = [];
/** A list of deprecation notes from the commit. */
const deprecations: ParsedCommit.Note[] = [];
const deprecations: CommitNote[] = [];

// Extract the commit message notes by marked types into their respective lists.
commit.notes.forEach((note: ParsedCommit.Note) => {
if (note.title === NoteSections.BREAKING_CHANGE) {
breakingChanges.push(note);
} else if (note.title === NoteSections.DEPRECATED) {
deprecations.push(note);
for (const note of commit.notes) {
switch (note.title) {
case NoteSections.BREAKING_CHANGE:
breakingChanges.push(note);
break;
case NoteSections.DEPRECATED:
deprecations.push(note);
break;
}
});
}

return {
fullText,
Expand All @@ -154,9 +164,9 @@ function parseInternal(fullText: string | Buffer): CommitFromGitLog | Commit {
footer: commit.footer || '',
header: commit.header || '',
references: commit.references,
scope: commit.scope || '',
subject: commit.subject || '',
type: commit.type || '',
scope: commit['scope'] || '',
subject: commit['subject'] || '',
type: commit['type'] || '',
isFixup: FIXUP_PREFIX_RE.test(fullText),
isSquash: SQUASH_PREFIX_RE.test(fullText),
isRevert: REVERT_PREFIX_RE.test(fullText),
Expand Down
3 changes: 1 addition & 2 deletions ng-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@octokit/types": "14.1.0",
"@pnpm/dependency-path": "1001.1.0",
"@types/cli-progress": "3.11.6",
"@types/conventional-commits-parser": "5.0.1",
"@types/ejs": "3.1.5",
"@types/events": "3.0.3",
"@types/folder-hash": "4.0.4",
Expand All @@ -50,7 +49,7 @@
"chalk": "5.6.2",
"cli-progress": "3.12.0",
"conventional-commits-filter": "5.0.0",
"conventional-commits-parser": "5.0.0",
"conventional-commits-parser": "6.2.0",
"ejs": "3.1.10",
"encoding": "0.1.13",
"fast-glob": "3.3.3",
Expand Down
1 change: 0 additions & 1 deletion ng-dev/pr/rebase/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ts_project(
"//ng-dev:__subpackages__",
],
deps = [
"//ng-dev:node_modules/@types/conventional-commits-parser",
"//ng-dev:node_modules/@types/node",
"//ng-dev:node_modules/@types/yargs",
"//ng-dev:node_modules/conventional-commits-parser",
Expand Down
2 changes: 1 addition & 1 deletion ng-dev/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"esModuleInterop": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"moduleResolution": "bundler",
"module": "esnext",
"target": "es2020",
"lib": ["es2021", "dom"],
Expand Down
78 changes: 12 additions & 66 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading