You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changelog now includes flat and grouped templates by default, choosing
to group templates according to the Groupings array in external config.
Grouped output now ensures the order of groupings based on the order
they're declared in external config.
Adds simple tests for changelog write outputs.
Copy file name to clipboardExpand all lines: README.md
+66-20Lines changed: 66 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,15 @@ Help Options:
34
34
35
35
The changelog output is written to standard output and can be redirected to overwrite or append to a file.
36
36
37
+
### Limitations
38
+
39
+
As this tool uses GitHub's comparison API for details, there are a few limitations to output:
40
+
41
+
* Limited to 250 commits
42
+
* Limited to 5000 API requests per hour
43
+
44
+
See the [GitHub Commits API](https://developer.github.com/v3/repos/commits/#compare-two-commits) for additional details.
45
+
37
46
### Basic
38
47
39
48
The changelog generator doesn't assume a start or end tag, and doesn't evaluate existing tags to determine tag order. If `from` and `to` options are not provided, your changelog will result in the single latest commit on `master`.
@@ -70,22 +79,56 @@ You may specify `GITHUB_OWNER` and `GITHUB_REPO` as environment variables for us
70
79
<em>For more details, see <a href="https://github.com/jimschubert/kopper/compare/v0.0.2...v0.0.3">v0.0.2..v0.0.3</a></em>
71
80
```
72
81
73
-
#### Default Template
82
+
#### Templating
83
+
84
+
The default template used in basic usage will output Markdown in flatten or grouped display (see later for configuration options). The template is defined as:
74
85
75
-
The default template used in basic usage will output Markdown. The template is defined as:
86
+
```gotemplate
87
+
{{define "GroupTemplate" -}}
88
+
{{- range .Grouped}}
89
+
### {{ .Name }}
76
90
91
+
{{range .Items -}}
92
+
* [{{.CommitHashShort}}]({{.CommitURL}}) {{.Title}} ({{if .IsPull}}[contributed]({{.PullURL}}) by {{end}}[{{.Author}}]({{.AuthorURL}}))
93
+
{{end -}}
94
+
{{end -}}
95
+
{{end -}}
96
+
{{define "FlatTemplate" -}}
97
+
{{range .Items -}}
98
+
* [{{.CommitHashShort}}]({{.CommitURL}}) {{.Title}} ({{if .IsPull}}[contributed]({{.PullURL}}) by {{end}}[{{.Author}}]({{.AuthorURL}}))
99
+
{{end -}}
100
+
{{end -}}
101
+
{{define "DefaultTemplate" -}}
102
+
## {{.Version}}
103
+
{{if len .Grouped -}}
104
+
{{template "GroupTemplate" . -}}
105
+
{{- else}}
106
+
{{template "FlatTemplate" . -}}
107
+
{{end}}
108
+
<em>For more details, see <a href="{{.CompareURL}}">{{.PreviousVersion}}..{{.Version}}</a></em>
109
+
{{end -}}
110
+
{{template "DefaultTemplate" . -}}
77
111
```
112
+
113
+
Groupings will be displayed in the order they're defined in your external configuration.
114
+
115
+
You must define an external JSON configuration file to override the default template. For example, suppose you want to display flat commit history and link to diff, patch, and compare URLs. You could define a template like so:
116
+
117
+
```gotemplate
78
118
## {{.Version}}
79
119
80
120
{{range .Items -}}
81
121
* [{{.CommitHashShort}}]({{.CommitURL}}) {{.Title}} ({{if .IsPull}}[contributed]({{.PullURL}}) by {{end}}[{{.Author}}]({{.AuthorURL}}))
82
122
{{end}}
83
123
84
-
<em>For more details, see <a href="{{.CompareURL}}">{{.PreviousVersion}}..{{.Version}}</a></em>
Currently, you must define an external JSON configuration file to override the default template.
88
-
89
132
## Install
90
133
91
134
Latest binary releases are available via [GitHub Releases](https://github.com/jimschubert/changelog/releases).
@@ -140,29 +183,30 @@ More advanced scenarios require an external JSON configuration object which can
140
183
}
141
184
```
142
185
143
-
### Grouping
186
+
### Custom templating
144
187
145
-
Grouping is done by the `name` property of the groupings array objects. You will want to provide a custom template to display groupings.
188
+
Grouping is done by the `name` property of the groupings array objects, in the order in which groupings are declared.
189
+
Groupings are displayed by default, but suppose you want to provide a custom template to display grouping differently. In this example, we'll only display the author name if the commit comes from a pull request.
146
190
147
-
For example, create a directory at `/tmp/changelog` to contain a sample JSON and template.
191
+
First, create a directory at `/tmp/changelog` to contain a sample JSON and template.
148
192
149
193
Save the follow **template** as `template.tmpl`:
150
194
151
195
```gotemplate
152
196
## {{.Version}}
153
197
154
-
{{range $key, $value := .Grouped -}}
155
-
### {{ $key }}
198
+
{{range .Grouped -}}
199
+
### {{ .Name }}
156
200
157
-
{{range $value -}}
158
-
* [{{.CommitHashShort}}]({{.CommitURL}}) {{.Title}} ({{if .IsPull}}[contributed]({{.PullURL}}) by {{end}}[{{.Author}}]({{.AuthorURL}}))
201
+
{{range .Items -}}
202
+
* [{{.CommitHashShort}}]({{.CommitURL}}) {{.Title}}{{if .IsPull}} ([contributed]({{.PullURL}}) by [{{.Author}}]({{.AuthorURL}})){{end}}
159
203
{{end}}
160
204
{{end}}
161
205
162
206
<em>For more details, see <a href="{{.CompareURL}}">{{.PreviousVersion}}..{{.Version}}</a></em>
163
207
```
164
208
165
-
And save the following as `config.json` (note: template currently requires a full path to the template file):
209
+
Save the following as `config.json` (note: template currently requires a full path to the template file):
166
210
167
211
```json
168
212
{
@@ -232,22 +276,24 @@ This changelog output in `/tmp/changelog/CHANGELOG.md` should look like this:
232
276
233
277
### Fixes
234
278
235
-
* [4c3e498021](https://github.com/cli/cli/commit/4c3e498021997b40d3c78f8c858ed734f819b064) Fix column alignment and truncation for Eastern Asian languages ([mislav](https://github.com/mislav))
236
-
* [4ee995dafd](https://github.com/cli/cli/commit/4ee995dafdf98730c292c63c1b8a0fab5f2198d1) fix(486): Getting issue list on no remotes specified ([yashLadha](https://github.com/yashLadha))
237
-
* [f9649ebddd](https://github.com/cli/cli/commit/f9649ebddd1b6a9731046c98cd8019a245c82fde) Merge pull request #521 from yashLadha/bug/issue_list_on_no_remote ([mislav](https://github.com/mislav))
279
+
* [f9649ebddd](https://github.com/cli/cli/commit/f9649ebddd1b6a9731046c98cd8019a245c82fde) Merge pull request #521 from yashLadha/bug/issue_list_on_no_remote ([contributed](https://github.com/cli/cli/pull/521) by [mislav](https://github.com/mislav))
280
+
* [4ee995dafd](https://github.com/cli/cli/commit/4ee995dafdf98730c292c63c1b8a0fab5f2198d1) fix(486): Getting issue list on no remotes specified
281
+
* [4c3e498021](https://github.com/cli/cli/commit/4c3e498021997b40d3c78f8c858ed734f819b064) Fix column alignment and truncation for Eastern Asian languages
238
282
239
283
### Other Contributions
240
284
241
-
* [4727fc4659](https://github.com/cli/cli/commit/4727fc465982d3029324fc5b77ee37e28c29a2b3) Ensure descriptive error when no github.com remotes found ([mislav](https://github.com/mislav))
242
-
* [69304ce9af](https://github.com/cli/cli/commit/69304ce9af6100e49bb6a128a81639d48ac590ec) Merge pull request #518 from cli/eastern-asian ([mislav](https://github.com/mislav))
243
-
* [1a82e39ba9](https://github.com/cli/cli/commit/1a82e39ba9627654aca22e9608d5b81589855d41) Respect title & body from arguments to `pr create -w` ([mislav](https://github.com/mislav))
244
-
* [b5d0b7c640](https://github.com/cli/cli/commit/b5d0b7c640ad897f395a72074a0f4b31787e5826) Merge pull request #523 from cli/title-body-web ([mislav](https://github.com/mislav))
285
+
* [b5d0b7c640](https://github.com/cli/cli/commit/b5d0b7c640ad897f395a72074a0f4b31787e5826) Merge pull request #523 from cli/title-body-web ([contributed](https://github.com/cli/cli/pull/523) by [mislav](https://github.com/mislav))
286
+
* [1a82e39ba9](https://github.com/cli/cli/commit/1a82e39ba9627654aca22e9608d5b81589855d41) Respect title & body from arguments to `pr create -w`
287
+
* [69304ce9af](https://github.com/cli/cli/commit/69304ce9af6100e49bb6a128a81639d48ac590ec) Merge pull request #518 from cli/eastern-asian ([contributed](https://github.com/cli/cli/pull/518) by [mislav](https://github.com/mislav))
288
+
* [4727fc4659](https://github.com/cli/cli/commit/4727fc465982d3029324fc5b77ee37e28c29a2b3) Ensure descriptive error when no github.com remotes found
245
289
246
290
247
291
248
292
<em>For more details, see <a href="https://github.com/cli/cli/compare/v0.5.6...v0.5.7">v0.5.6..v0.5.7</a></em>
249
293
```
250
294
295
+
Notice that this differs from the default in that it removes the committer name from the two commits in each section which were not pull requests.
296
+
251
297
### Debugging
252
298
253
299
You may debug select operations such as groupings and exclusions by exporting `LOG_LEVEL=debug`.
0 commit comments