Skip to content

Commit

Permalink
Ignore unreleased commits
Browse files Browse the repository at this point in the history
  • Loading branch information
Drarig29 committed Dec 21, 2020
1 parent 3753c2d commit d913b74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion source/git-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const firstCommit = async () => {
return stdout;
};

exports.tagBeforeCurrentOrFirstCommit = async () => {
exports.previousTagOrFirstCommit = async () => {
const {stdout} = await execa('git', ['tag']);
const tags = stdout.split('\n');

Expand Down
15 changes: 8 additions & 7 deletions source/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const {prereleaseTags, checkIgnoreStrategy, getRegistryUrl, isExternalRegistry}
const version = require('./version');
const prettyVersionDiff = require('./pretty-version-diff');

const printCommitLog = async (repoUrl, registryUrl, latestTag) => {
const revision = latestTag ? await git.latestTagOrFirstCommit() : await git.tagBeforeCurrentOrFirstCommit();
const printCommitLog = async (repoUrl, registryUrl, fromLatestTag) => {
const revision = fromLatestTag ? await git.latestTagOrFirstCommit() : await git.previousTagOrFirstCommit();
if (!revision) {
throw new Error('The package hasn\'t been published yet.');
}
Expand All @@ -35,12 +35,13 @@ const printCommitLog = async (repoUrl, registryUrl, latestTag) => {
};
});

if (!latestTag) {
// Remove the version bump commit from the commit list.
if (!fromLatestTag) {
const latestTag = await git.latestTag();
if (latestTag.match(commits[0].message)) {
commits = commits.slice(1);
}
const versionBumpCommitName = latestTag.slice(1); // Name v1.0.1 becomes 1.0.1
const versionBumpCommitIndex = commits.findIndex(commit => commit.message === versionBumpCommitName);

// Get rid of unreleased commits and of the version bump commit.
commits = commits.slice(versionBumpCommitIndex + 1);
}

const history = commits.map(commit => {
Expand Down

0 comments on commit d913b74

Please sign in to comment.