Skip to content

Commit

Permalink
fix: add better debugging messages for decisions around conventional …
Browse files Browse the repository at this point in the history
…commits
  • Loading branch information
mscharley committed Jun 26, 2024
1 parent 957cf1f commit 63f9c50
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion dist/index.js

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

8 changes: 8 additions & 0 deletions src/parseConventionalCommitMessage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { debug } from '@actions/core';

const conventionalCommit = /^(\w+)(?:\((\w+)\))?(!?):\s*(.*)(?:\n\n(.*))?$/u;

/**
* Parses a commit message into a release type
*/
export const parseConventionalCommitMessage = (message: string): 'major' | 'minor' | 'patch' | 'none' => {
debug(`Treating commit message as a conventional commit: ${message}`);
const match = message.match(conventionalCommit) as
| null
| [string, string, string | undefined, '!' | undefined, string, string | undefined];
Expand All @@ -14,14 +17,19 @@ export const parseConventionalCommitMessage = (message: string): 'major' | 'mino
const [, type, _scope, major, _msg, body] = match;

if ((body ?? '').match(/^BREAKING[- ]CHANGE:/mu) != null) {
debug('Treating this commit as a major update.');
return 'major';
} else if (major === '!') {
debug('Treating this commit as a major update.');
return 'major';
} else if (type === 'fix') {
debug('Treating this commit as a patch update.');
return 'patch';
} else if (type === 'feat') {
debug('Treating this commit as a minor update.');
return 'minor';
}

debug('No releaseable change in the commit message, ignoring this commit.');
return 'none';
};

0 comments on commit 63f9c50

Please sign in to comment.