MCPcopy Create free account
hub / github.com/angular/dev-infra / parseInternal

Function parseInternal

ng-dev/commit-message/parse.ts:131–175  ·  view source on GitHub ↗

Parse a full commit message into its composite parts.

(fullText: string)

Source from the content-addressed store, hash-verified

129/** Parse a commit message into its composite parts. */
130export const parseCommitMessage: (fullText: string) => Commit = parseInternal;
131
132/** Parse a commit message from a git log entry into its composite parts. */
133export function parseCommitFromGitLog(fullText: string): CommitFromGitLog {
134 return parseInternal(fullText) as CommitFromGitLog;
135}
136
137/** Parse a full commit message into its composite parts. */
138function parseInternal(fullText: string): CommitFromGitLog | Commit {
139 const metadataMatch = fullText.match(GIT_LOG_METADATA_RE);
140 const messageText = metadataMatch ? fullText.slice(0, metadataMatch.index) : fullText;
141 const hash = metadataMatch?.[1]?.trim() || undefined;
142 const shortHash = metadataMatch?.[2]?.trim() || undefined;
143 const author = metadataMatch?.[3]?.trim() || undefined;
144
145 /** The initially parsed commit. */
146 const commit = commitParser.parse(messageText);
147 /** A list of breaking change notes from the commit. */
148 const breakingChanges: CommitNote[] = [];
149 /** A list of deprecation notes from the commit. */
150 const deprecations: CommitNote[] = [];
151 /** The extracted header after stripping away fixup, squash, etc. */
152 const header = (commit.header || '')
153 .replace(FIXUP_PREFIX_RE, '')
154 .replace(SQUASH_PREFIX_RE, '')
155 .replace(REVERT_PREFIX_RE, '');
156
157 // Extract the commit message notes by marked types into their respective lists.
158 for (const note of commit.notes) {
159 switch (note.title) {
160 case NoteSections.BREAKING_CHANGE:
161 breakingChanges.push(note);
162 break;
163 case NoteSections.DEPRECATED:
164 deprecations.push(note);
165 break;
166 }
167 }
168
169 return {
170 fullText,
171 breakingChanges,
172 deprecations,
173 header,
174 body: commit.body || '',
175 footer: commit.footer || '',
176 originalHeader: commit.header || '',
177 references: commit.references,
178 scope: commit['scope'] || '',

Callers 1

parseCommitFromGitLogFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected