Skip to content

Commit

Permalink
fix(writer): fix commit URL for Gitlab repos (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
AvraamMavridis authored and robinjoseph08 committed Mar 28, 2018
1 parent 797909e commit 656a2bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ exports.getCommitUrl = function (baseUrl, commitHash) {
urlCommitName = 'commits';
}

if (baseUrl.indexOf('gitlab') !== -1 && baseUrl.slice(-4) === '.git') {
baseUrl = baseUrl.slice(0, -4);
}

return baseUrl + '/' + urlCommitName + '/' + commitHash;
};

Expand Down
9 changes: 9 additions & 0 deletions test/writer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ describe('writer', function () {
Expect(linkUrl).to.equal(url + '/commit/' + commitHash);
});

it('makes a valid URL for a Gitlab repository', function () {
var url = 'https://gitlab.com/lob/generate-changelog.git';
var expectedUrl = 'https://gitlab.com/lob/generate-changelog';
var commitHash = '1234567890';

var linkUrl = Writer.getCommitUrl(url, commitHash);
Expect(linkUrl).to.equal(expectedUrl + '/commit/' + commitHash);
});

});

describe('markdown', function () {
Expand Down

0 comments on commit 656a2bc

Please sign in to comment.