Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Commit

Permalink
feat(context): fallback to repoUrl
Browse files Browse the repository at this point in the history
Because of the new get-repo-url, host always returns something with unknown host. So we need to create a new context, repoUrl here to contain `browse()` url.

Fixes #7
  • Loading branch information
stevemao committed May 10, 2016
1 parent c80e05a commit da0b096
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/merge-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ function mergeConfig(options, context, gitRawCommitsOpts, parserOpts, writerOpts
context.host = context.host || (repo.domain ? (parsedBrowse.protocol + (parsedBrowse.slashes ? '//' : '') + repo.domain) : null);
context.owner = context.owner || repo.user || '';
context.repository = context.repository || repo.project;

if (!context.host && !context.owner && !context.repository) {
context.repository = browse;
}
context.repoUrl = browse;
}

context.packageData = pkg;
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ Default: extracted from normalized `package.json` `repository.url` field.

Default: extracted from normalized `package.json` `repository.url` field.

##### repoUrl

Default: The whole normalized repository url in `package.json`.

##### gitSemverTags

Type: `array`
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/_unknown-host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": "0.0.17",
"repository": {
"type": "git",
"url": "https://stash.local/scm/conventional-changelog/conventional-changelog.git"
}
}
19 changes: 18 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('conventionalChangelogCore', function() {
}));
});

it('should only print the host', function(done) {
it('should fallback to use repo url if repo is repository is null', function(done) {
conventionalChangelogCore({
pkg: {
path: __dirname + '/fixtures/_host-only.json'
Expand All @@ -199,6 +199,23 @@ describe('conventionalChangelogCore', function() {
}));
});

it('should fallback to use repo url if repo is repository is null', function(done) {
conventionalChangelogCore({
pkg: {
path: __dirname + '/fixtures/_unknown-host.json'
}
}, {
linkReferences: true
}).pipe(through(function(chunk) {
chunk = chunk.toString();

expect(chunk).to.include('](https://stash.local/scm/conventional-changelog/conventional-changelog/commits/');
expect(chunk).to.include('closes [#1](https://stash.local/scm/conventional-changelog/conventional-changelog/issues/1)');

done();
}));
});

it('should transform package.json data', function(done) {
conventionalChangelogCore({
pkg: {
Expand Down

0 comments on commit da0b096

Please sign in to comment.