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

Commit

Permalink
fix(unknownHost): default context.repository
Browse files Browse the repository at this point in the history
`context.repository` should only fallback to `browse` if `context.host`, `context.owner` and `context.repository` do not exist.
  • Loading branch information
stevemao committed Apr 18, 2016
1 parent f04a83e commit eaa3b6f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion lib/merge-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ function mergeConfig(options, context, gitRawCommitsOpts, parserOpts, writerOpts
var parsedBrowse = url.parse(browse);
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 || browse;
context.repository = context.repository || repo.project;

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

context.packageData = pkg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"version": "0.0.17",
"repository": {
"type": "git",
"url": "https://unknown-host/a/b.git"
"url": "https://unknown-host/.git"
}
}
8 changes: 4 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,18 @@ describe('conventionalChangelogCore', function() {
}));
});

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

expect(chunk).to.include('](https://unknown-host/a/b/commits/');
expect(chunk).to.include('closes [#1](https://unknown-host/a/b/issues/1)');
expect(chunk).to.include('](https://unknown-host/commits/');
expect(chunk).to.include('closes [#1](https://unknown-host/issues/1)');

done();
}));
Expand Down

0 comments on commit eaa3b6f

Please sign in to comment.