UNPKG

903 BJavaScriptView Raw
1const debug = require('debug')('semantic-release:get-commits');
2const {getCommits} = require('./git');
3
4/**
5 * Retrieve the list of commits on the current branch since the commit sha associated with the last release, or all the commits of the current branch if there is no last released version.
6 *
7 * @param {Object} context semantic-release context.
8 *
9 * @return {Promise<Array<Object>>} The list of commits on the branch `branch` since the last release.
10 */
11module.exports = async ({cwd, env, lastRelease: {gitHead: from}, nextRelease: {gitHead: to = 'HEAD'} = {}, logger}) => {
12 if (from) {
13 debug('Use from: %s', from);
14 } else {
15 logger.log('No previous release found, retrieving all commits');
16 }
17
18 const commits = await getCommits(from, to, {cwd, env});
19
20 logger.log(`Found ${commits.length} commits since last release`);
21 debug('Parsed commits: %o', commits);
22 return commits;
23};