Skip to content

Commit

Permalink
fix: use full commit hashes for links
Browse files Browse the repository at this point in the history
  • Loading branch information
qoomon committed Mar 2, 2023
1 parent a597d5d commit 5901fc5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## **2.6.3**&emsp;<sub><sup>2023-03-02 ([ad1d56c...a64d54f](https://github.com/qoomon/git-conventional-commits/compare/ad1d56c...a64d54f?diff=split))</sup></sub>

### Bug Fixes
* use full commit hashes for links ([a64d54f](https://github.com/qoomon/git-conventional-commits/commit/a64d54f))

<br>

## **2.6.0**&emsp;<sub><sup>2023-02-28 ([aafcc05...aafcc05](https://github.com/qoomon/git-conventional-commits/compare/aafcc05...aafcc05?diff=split))</sup></sub>

### Features
Expand Down
5 changes: 3 additions & 2 deletions lib/changelogGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ module.exports = function (config) {

function markdownCommitRange(formCommitHash, toCommitHash) {
if (config.commitRangeUrl) {
const commitRangeUrl = config.commitRangeUrl.replace("%from%", formCommitHash).replace("%to%",
toCommitHash);
const commitRangeUrl = config.commitRangeUrl
.replace("%from%", formCommitHash)
.replace("%to%", toCommitHash);
return markdownLink(`${formCommitHash.substring(0, 7)}...${toCommitHash.substring(0, 7)}`, commitRangeUrl);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const LOG_COMMIT_DELIMITER = '===LOG_COMMIT_DELIMITER===';
const LOG_FIELD_SEPARATOR = '===LOG_FIELD_SEPARATOR===';

async function getCommitLog(from, to = 'HEAD') {
const gitLogFormat = ["%h", "%aI", "%s", "%b"].join(LOG_FIELD_SEPARATOR) + LOG_COMMIT_DELIMITER;
const gitLogFormat = ["%H", "%aI", "%s", "%b"].join(LOG_FIELD_SEPARATOR) + LOG_COMMIT_DELIMITER;
const gitLog = await execAsync(`git log --reverse --format=${gitLogFormat} ${from ? `${from}..` : ''}${to}`, {encoding: 'UTF-8'})
.then(result => result.split(LOG_COMMIT_DELIMITER + '\n').slice(0, -1))
.catch(err => {
Expand Down
2 changes: 1 addition & 1 deletion lib/gitCommitConvention.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module.exports = function (convention, commitAnchor = 'HEAD') {
conventionalSubject = parseCommitSubject(conventionalSubject);
conventionalSubject.revert = !conventionalSubject.revert; // negate revert of revert commit
} else {
console.warn(`[WARN] ${commit.hash ? `${commit.hash} - ` : ''}Invalid commit subject format: '${commit.subject}'`);
console.warn(`[WARN] ${commit.hash ? `${commit.hash.substring(0, 7)} - ` : ''}Invalid commit subject format: '${commit.subject}'`);
return conventionalSubject;
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "git-conventional-commits",
"version": "2.6.2",
"version": "2.6.3",
"description": "git conventional commits util",
"licence": "GPLv3",
"main": "cli.js",
Expand Down

0 comments on commit 5901fc5

Please sign in to comment.