-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misc(changelog-generator): Generate changelogs #3632
Changes from 12 commits
623c4cc
6b78e85
11634e2
afe3364
7b0ac70
0d77fa9
8e26dfd
01efa91
0d916a1
055700b
259afcf
b124091
e7d5ba5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* @license Copyright 2017 Google Inc. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
'use strict'; | ||
const readFileSync = require('fs').readFileSync; | ||
const resolve = require('path').resolve; | ||
const mainTemplate = readFileSync(resolve(__dirname, 'templates/template.hbs')).toString(); | ||
const headerPartial = readFileSync(resolve(__dirname, 'templates/header.hbs')).toString(); | ||
const commitPartial = readFileSync(resolve(__dirname, 'templates/commit.hbs')).toString(); | ||
|
||
const pullRequestRegex = /\(#(\d+)\)$/; | ||
const parserOpts = { | ||
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/, | ||
headerCorrespondence: [ | ||
'type', | ||
'scope', | ||
'message', | ||
], | ||
}; | ||
|
||
const writerOpts = { | ||
mainTemplate, | ||
headerPartial, | ||
commitPartial, | ||
transform: commit => { | ||
if (typeof commit.hash === 'string') { | ||
commit.hash = commit.hash.substring(0, 7); | ||
} | ||
|
||
if (commit.type === 'test') { | ||
commit.type = 'tests'; | ||
} | ||
|
||
if (commit.type) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we also de-dupe test and tests while we're in here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fine by me, I just copy pasted it 😊 |
||
commit.type = commit.type.replace(/_/g, ' '); | ||
commit.type = commit.type.substring(0, 1).toUpperCase() + commit.type.substring(1); | ||
} else { | ||
commit.type = 'Misc'; | ||
} | ||
|
||
let pullRequestMatch = commit.header.match(pullRequestRegex); | ||
// if header does not provide a PR we try the message | ||
if (!pullRequestMatch && commit.message) { | ||
pullRequestMatch = commit.message.match(pullRequestRegex); | ||
} | ||
|
||
if (pullRequestMatch) { | ||
commit.header = commit.header.replace(pullRequestMatch[0], ''); | ||
if (commit.message) { | ||
commit.message = commit.message.replace(pullRequestMatch[0], ''); | ||
} | ||
|
||
commit.PR = pullRequestMatch[1]; | ||
} | ||
|
||
return commit; | ||
}, | ||
groupBy: 'type', | ||
commitGroupsSort: (a, b) => { | ||
// put new audit on the top | ||
if (a.title === 'New audit') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we similarly force |
||
return -1; | ||
} | ||
if (b.title === 'New audit') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't working for me. I think you also need to handle the other case, too ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my mistake! it works now! |
||
return 1; | ||
} | ||
|
||
return a.title.localeCompare(b.title); | ||
}, | ||
commitsSort: ['type', 'scope'], | ||
}; | ||
|
||
module.exports = { | ||
writerOpts, | ||
parserOpts, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{{!-- | ||
/** | ||
* @license Copyright 2017 Google Inc. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
--}} | ||
* {{#if scope}}{{scope}}: {{/if~}} | ||
{{#if message ~}} | ||
{{~message~}} | ||
{{~else~}} | ||
{{~header~}} | ||
{{~/if ~}} | ||
{{~!-- commit hash --}} | ||
{{~#if @root.linkReferences~}} | ||
{{~#if PR ~}} | ||
([#{{PR}}]( | ||
{{~#if @root.host}}{{~@root.host}}/{{/if~}} | ||
{{~#if @root.owner ~}}{{@root.owner}}/{{/if~}} | ||
{{~@root.repository}}/pull/{{PR}})) | ||
{{~else~}} | ||
([{{hash}}]( | ||
{{~#if @root.host}}{{~@root.host}}/{{/if~}} | ||
{{~#if @root.owner ~}}{{@root.owner}}/{{/if~}} | ||
{{~@root.repository}}/{{@root.commit}}/{{hash}})) | ||
{{~/if~}} | ||
{{~else~}} | ||
{{~hash~}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{{~/if~}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{!-- | ||
/** | ||
* @license Copyright 2017 Google Inc. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
--}} | ||
<a name="{{version}}"></a> | ||
# {{version}} ({{date}}) | ||
{{#if @root.linkCompare~}} | ||
[Full Changelog]({{~@root.repoUrl}}/compare/{{previousTag}}...{{currentTag}}) | ||
{{~/if}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{!-- | ||
/** | ||
* @license Copyright 2017 Google Inc. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
--}} | ||
{{> header}} | ||
|
||
{{#each commitGroups}} | ||
|
||
{{#if title~}} | ||
### {{title}} | ||
|
||
{{/if}} | ||
{{#each commits}} | ||
{{~> commit root=@root}} | ||
|
||
{{/each}} | ||
{{/each}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs license header