Skip to content

Commit

Permalink
fix: set shortHash to commit object
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Oct 14, 2019
1 parent 20fdb01 commit 7c3b24c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/commit-transform.js
Expand Up @@ -31,7 +31,7 @@ module.exports = (commit, context) => {
}

if (typeof commit.hash === 'string') {
commit.hash = commit.hash.substring(0, COMMIT_HASH_LENGTH);
commit.shortHash = commit.hash.substring(0, COMMIT_HASH_LENGTH);
}

const references = [];
Expand Down
2 changes: 1 addition & 1 deletion test/commit-transform.test.js
Expand Up @@ -15,7 +15,7 @@ test('Return transformed commit and truncate hash', t => {

t.is(commit.type, 'feat');
t.is(commit.groupType, 'Feature title');
t.is(commit.hash.length, COMMIT_HASH_LENGTH);
t.is(commit.shortHash.length, COMMIT_HASH_LENGTH);
t.true('1234567890'.startsWith(commit.hash));
});

Expand Down
3 changes: 1 addition & 2 deletions test/preset.test.js
Expand Up @@ -57,10 +57,9 @@ test.serial('Create commit link', async t => {
{types: {fix: {title: 'Fix title', changelog: true}}},
{pkg: {path: path.join(__dirname, '/fixtures/_package.json')}}
);
const [, hash, url] = /\(\[(.*?)\]\((.*?)\)\)/.exec(log);
const [, hash] = /\(\[(.*?)\]\(.*?\)\)/.exec(log);

t.is(hash.length, COMMIT_HASH_LENGTH);
t.is(url, `https://github.com/github_user/repo_name/commit/${hash}`);
});

test.serial('Create reference link', async t => {
Expand Down

0 comments on commit 7c3b24c

Please sign in to comment.