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

Commit

Permalink
fix(template): default commit template should handle unkown host
Browse files Browse the repository at this point in the history
Ignore host and owner if they do not exist and just use repository to link
  • Loading branch information
stevemao committed Sep 30, 2015
1 parent 66a44a4 commit ef62bfd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions templates/commit.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
* {{header}}

{{~!-- commit hash --}} {{#if @root.linkReferences}}([{{hash}}]({{@root.host}}/{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/{{@root.commit}}/{{hash}})){{else}}{{hash~}}{{/if}}
{{~!-- commit hash --}} {{#if @root.linkReferences}}([{{hash}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/{{@root.commit}}/{{hash}})){{else}}{{hash~}}{{/if}}

{{~!-- commit references --}}{{#if references}}, closes{{~#each references}} {{#if @root.linkReferences}}[{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}]({{@root.host}}/{{#if this.repository}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{else}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}{{/if}}/{{@root.issue}}/{{this.issue}}){{else}}{{this.repository}}#{{this.issue}}{{/if}}{{/each}}{{/if}}
{{~!-- commit references --}}{{#if references}}, closes{{~#each references}} {{#if @root.linkReferences}}[{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if this.repository}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{else}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}{{/if}}/{{@root.issue}}/{{this.issue}}){{else}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}{{/if}}{{/each}}{{/if}}
16 changes: 16 additions & 0 deletions test/partial.commit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ beforeEach(function() {
});

describe('partial.commit', function() {
it('should ignore host and owner if they do not exist and just use repository to link', function() {
var log = Handlebars.compile(template)({
header: 'my header',
repository: 'www.myhost.com/a/b',
commit: 'my commits',
issue: 'my issue',
hash: 'hash',
linkReferences: true,
references: [{
issue: 1
}]
});

expect(log).to.equal('* my header ([hash](www.myhost.com/a/b/my commits/hash)), closes [#1](www.myhost.com/a/b/my issue/1)\n');
});

it('should not link the commit if `linkReferences` is falsy', function() {
var log = Handlebars.compile(template)(templateContext);

Expand Down

0 comments on commit ef62bfd

Please sign in to comment.