How to use conventional-commits-parser - 10 common examples

To help you get started, we’ve selected a few conventional-commits-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github material-components / material-components-web / scripts / cherry-pick-commits.js View on Github external
function shouldSkipCommit(logLine, mode) {
  const parsedCommit = parser.sync(logLine.message, parserOpts);
  return (parsedCommit.type === 'feat' && mode === 'patch') || // feature commit
    parsedCommit.notes.find((note) => note.title === 'BREAKING CHANGE') || // breaking change commit
    (parsedCommit.type === 'chore' && parsedCommit.subject === 'Publish'); // Publish (version-rev) commit
}
github hahow / probot-conventional-release / lib / convertToConventionalCommit.js View on Github external
module.exports = ({ commit: { author, message }, sha }) => {
  const parserOptions = {
    // 預設的 headerPattern 是 /^(\w*)(?:\(([\w\$\.\-\* ]*)\))?\: (.*)$/
    // 但我們的 scope 有斜線的需求,例如:fix(controllers/auth): oauth login failed
    // 固修改 headerPattern 支援斜線(/)。
    headerPattern: /^(\w*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$/
  }
  const conventionalCommit = conventionalCommitsParser.sync(message, parserOptions)

  return {
    conventionalCommit,
    sha,
    author
  }
}
github kazupon / git-commit-message-convention / test / footer.js View on Github external
test('notes: undefined note', (t) => {
  let commit = ':bug: fix(chat): broadcast $destroy event on scope destruction (by @kazupon)\n'
    + '\n'
    + 'TODO:\n'
    + 'this is note ...'
  let parsed = parser.sync(commit, options)
  t.deepEqual(parsed.notes, [])
})
github kazupon / git-commit-message-convention / test / footer.js View on Github external
test('basic', (t) => {
  let commit = ':bug: fix(chat): broadcast $destroy event on scope destruction (by @kazupon)\n'
    + '\n'
    + 'this is the body\n'
    + '\n'
    + 'NOTE:\n'
    + 'this is the note\n'
    + '\n'
    + 'Closes #1'
  let parsed = parser.sync(commit, options)
  t.is(parsed.footer, 'NOTE:\nthis is the note\n\nCloses #1')
})
github rollup / plugins / scripts / publish.js View on Github external
.map((commit) => {
      const node = parser.sync(commit);

      node.breaking = reBreaking.test(node.body || node.footer);

      return node;
    });
github Esri / arcgis-rest-js / support / changelog.js View on Github external
.map(commit => {
        const parsedCommit = parseCommit(
          execSync(
            `git log ${commit.hash} -n1 --pretty=format:'%B'`
          ).toString(),
          {
            mergePattern: /^Merge pull request #(\d+) from (.*)$/,
            mergeCorrespondence: ["id", "source"],
            noteKeywords: [
              "BREAKING CHANGE",
              "ISSUES CLOSED",
              "AFFECTS PACKAGES"
            ]
          }
        );
        if (!parsedCommit.type || !parsedCommit.scope) {
          return;
        }
github groupon / nlm / lib / git / commits.js View on Github external
function parseCommit(commit) {
  const metaEndIdx = commit.indexOf('\n');
  const meta = commit
    .slice(0, metaEndIdx)
    .trim()
    .split(' ');
  const message = commit.slice(metaEndIdx + 1);

  const sha = meta.shift();
  const parentSha = meta.shift() || null;

  const data = commitParser.sync(message, {
    issuePrefixes: ['#', 'https?://[\\w\\.-/]*[-/]+'],
  });
  const prMatch = message.match(PR_MERGE_PATTERN);
  if (prMatch) {
    const prId = prMatch[1];
    data.type = 'pr';
    data.pullId = prId;
    const mergeRef = data.references.find(ref => {
      return ref.issue === prId;
    });
    if (!mergeRef) {
      throw new Error(`Couldn't find reference to merge of PR #${prId}`);
    }
    Object.assign(mergeRef, {
      action: 'Merges',
      owner: prMatch[2],
github rollup / plugins / scripts / pub.js View on Github external
.map((commit) => {
      const node = parser.sync(commit);

      node.breaking = reBreaking.test(node.body || node.footer);

      return node;
    });
github semantic-release / commit-analyzer / lib / parse.js View on Github external
module.exports = (rawCommit, config) => {
  try {
    return parser(rawCommit, config);
  } catch (err) {
    throw new SemanticReleaseError(`Error in conventional-changelog-parser: ${err.message}`, err.code);
  }
};
github paeckchen / paeckchen / task.js View on Github external
.then(commits => commits.map(commit => {
          commit.message = conventionalCommitsParser.sync(commit.message);
          commit.message.hash = commit.hash;
          return commit.message;
        }))
        .then(commits => commits.filter(commit => commit.scope === packageDir))

conventional-commits-parser

Parse raw conventional commits.

ISC
Latest version published 8 months ago

Package Health Score

87 / 100
Full package analysis

Popular conventional-commits-parser functions