1
1
# -*- coding: utf-8; mode: python -*-
2
- import yaml
3
-
4
2
##
5
3
## Format
6
4
##
@@ -53,6 +51,7 @@ import yaml
53
51
## message will be displayed in the changelog without reformatting.
54
52
55
53
54
+ ##
56
55
## ``ignore_regexps`` is a line of regexps
57
56
##
58
57
## Any commit having its full commit message matching any regexp listed here
@@ -130,8 +129,18 @@ section_regexps = [
130
129
## whatever given ``msg`` if the current text is empty.
131
130
##
132
131
## Additionally, you can `pipe` the provided filters, for instance:
132
+ #body_process = Wrap(regexp=r'\n(?=\w+\s*:)') | Indent(chars=" ")
133
+ #body_process = Wrap(regexp=r'\n(?=\w+\s*:)')
134
+ #body_process = noop
133
135
body_process = ReSub (r'((^|\n)[A-Z]\w+(-\w+)*: .*(\n\s+.*)*)+$' , r'' ) | strip
134
136
137
+
138
+ ## ``subject_process`` is a callable
139
+ ##
140
+ ## This callable will be given the original subject and result will
141
+ ## be used in the changelog.
142
+ ##
143
+ ## Available constructs are those listed in ``body_process`` doc.
135
144
subject_process = (strip |
136
145
ReSub (r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n@]*)(@[a-z]+\s+)*$' , r'\4' ) |
137
146
SetIfEmpty ("No commit message." ) | ucfirst | final_dot )
@@ -144,39 +153,139 @@ subject_process = (strip |
144
153
tag_filter_regexp = r'^[0-9]+\.[0-9]+(\.[0-9]+)?$'
145
154
146
155
156
+ ## ``unreleased_version_label`` is a string or a callable that outputs a string
157
+ ##
158
+ ## This label will be used as the changelog Title of the last set of changes
159
+ ## between last valid tag and HEAD if any.
160
+ import yaml
161
+
147
162
with open ('vars/main.yml' ) as stream :
148
163
unreleased_version_label = yaml .safe_load (stream )['cassandra_role_version' ]
149
164
165
+ ## ``output_engine`` is a callable
166
+ ##
167
+ ## This will change the output format of the generated changelog file
168
+ ##
169
+ ## Available choices are:
170
+ ##
171
+ ## - rest_py
172
+ ##
173
+ ## Legacy pure python engine, outputs ReSTructured text.
174
+ ## This is the default.
175
+ ##
176
+ ## - mustache(<template_name>)
177
+ ##
178
+ ## Template name could be any of the available templates in
179
+ ## ``templates/mustache/*.tpl``.
180
+ ## Requires python package ``pystache``.
181
+ ## Examples:
182
+ ## - mustache("markdown")
183
+ ## - mustache("restructuredtext")
184
+ ##
185
+ ## - makotemplate(<template_name>)
186
+ ##
187
+ ## Template name could be any of the available templates in
188
+ ## ``templates/mako/*.tpl``.
189
+ ## Requires python package ``mako``.
190
+ ## Examples:
191
+ ## - makotemplate("restructuredtext")
192
+ ##
193
+ #output_engine = rest_py
194
+ #output_engine = mustache("restructuredtext")
150
195
output_engine = mustache ("markdown" )
196
+ #output_engine = makotemplate("restructuredtext")
197
+
198
+
199
+ ## ``include_merge`` is a boolean
200
+ ##
201
+ ## This option tells git-log whether to include merge commits in the log.
202
+ ## The default is to include them.
151
203
include_merge = False
152
- log_encoding = 'utf-8'
153
- OUTPUT_FILE = "CHANGELOG.md"
154
- INSERT_POINT_REGEX = r'''(?isxu)
155
- ^
156
- (
157
- \s*\#\s+Changelog\s*(\n|\r\n|\r) ## ``Changelog`` line
158
- )
159
-
160
- ( ## Match all between changelog and release rev
161
- (
162
- (?!
163
- (?<=(\n|\r)) ## look back for newline
164
- \#\#\s+%(rev)s ## revision
165
- \s+
166
- \([0-9]+-[0-9]{2}-[0-9]{2}\)(\n|\r\n|\r) ## date
167
- )
168
- .
169
- )*
170
- )
171
-
172
- (?P<tail>\#\#\s+(?P<rev>%(rev)s))
173
- ''' % {'rev' : r"[0-9]+\.[0-9]+(\.[0-9]+)?" }
174
-
175
- revs = [
176
- Caret (FileFirstRegexMatch (OUTPUT_FILE , INSERT_POINT_REGEX )),
177
- 'HEAD'
178
- ]
179
- publish = FileInsertAtFirstRegexMatch (
180
- OUTPUT_FILE , INSERT_POINT_REGEX ,
181
- idx = lambda m : m .start (1 )
182
- )
204
+
205
+
206
+ ## ``log_encoding`` is a string identifier
207
+ ##
208
+ ## This option tells gitchangelog what encoding is outputed by ``git log``.
209
+ ## The default is to be clever about it: it checks ``git config`` for
210
+ ## ``i18n.logOutputEncoding``, and if not found will default to git's own
211
+ ## default: ``utf-8``.
212
+ #log_encoding = 'utf-8'
213
+
214
+
215
+ ## ``publish`` is a callable
216
+ ##
217
+ ## Sets what ``gitchangelog`` should do with the output generated by
218
+ ## the output engine. ``publish`` is a callable taking one argument
219
+ ## that is an interator on lines from the output engine.
220
+ ##
221
+ ## Some helper callable are provided:
222
+ ##
223
+ ## Available choices are:
224
+ ##
225
+ ## - stdout
226
+ ##
227
+ ## Outputs directly to standard output
228
+ ## (This is the default)
229
+ ##
230
+ ## - FileInsertAtFirstRegexMatch(file, pattern, idx=lamda m: m.start(), flags)
231
+ ##
232
+ ## Creates a callable that will parse given file for the given
233
+ ## regex pattern and will insert the output in the file.
234
+ ## ``idx`` is a callable that receive the matching object and
235
+ ## must return a integer index point where to insert the
236
+ ## the output in the file. Default is to return the position of
237
+ ## the start of the matched string.
238
+ ##
239
+ ## - FileRegexSubst(file, pattern, replace, flags)
240
+ ##
241
+ ## Apply a replace inplace in the given file. Your regex pattern must
242
+ ## take care of everything and might be more complex. Check the README
243
+ ## for a complete copy-pastable example.
244
+ ##
245
+ # publish = FileInsertIntoFirstRegexMatch(
246
+ # "CHANGELOG.rst",
247
+ # r'/(?P<rev>[0-9]+\.[0-9]+(\.[0-9]+)?)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n/',
248
+ # idx=lambda m: m.start(1)
249
+ # )
250
+ #publish = stdout
251
+
252
+
253
+ ## ``revs`` is a list of callable or a list of string
254
+ ##
255
+ ## callable will be called to resolve as strings and allow dynamical
256
+ ## computation of these. The result will be used as revisions for
257
+ ## gitchangelog (as if directly stated on the command line). This allows
258
+ ## to filter exaclty which commits will be read by gitchangelog.
259
+ ##
260
+ ## To get a full documentation on the format of these strings, please
261
+ ## refer to the ``git rev-list`` arguments. There are many examples.
262
+ ##
263
+ ## Using callables is especially useful, for instance, if you
264
+ ## are using gitchangelog to generate incrementally your changelog.
265
+ ##
266
+ ## Some helpers are provided, you can use them::
267
+ ##
268
+ ## - FileFirstRegexMatch(file, pattern): will return a callable that will
269
+ ## return the first string match for the given pattern in the given file.
270
+ ## If you use named sub-patterns in your regex pattern, it'll output only
271
+ ## the string matching the regex pattern named "rev".
272
+ ##
273
+ ## - Caret(rev): will return the rev prefixed by a "^", which is a
274
+ ## way to remove the given revision and all its ancestor.
275
+ ##
276
+ ## Please note that if you provide a rev-list on the command line, it'll
277
+ ## replace this value (which will then be ignored).
278
+ ##
279
+ ## If empty, then ``gitchangelog`` will act as it had to generate a full
280
+ ## changelog.
281
+ ##
282
+ ## The default is to use all commits to make the changelog.
283
+ #revs = ["^1.0.3", ]
284
+ #revs = [
285
+ # Caret(
286
+ # FileFirstRegexMatch(
287
+ # "CHANGELOG.rst",
288
+ # r"(?P<rev>[0-9]+\.[0-9]+(\.[0-9]+)?)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n")),
289
+ # "HEAD"
290
+ #]
291
+ revs = []
0 commit comments