.gitchangelog.rc 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. # -*- coding: utf-8; mode: python -*-
  2. ##
  3. ## https://pypi.org/project/gitchangelog/
  4. ##
  5. ## Format
  6. ##
  7. ## ACTION: [AUDIENCE:] COMMIT_MSG [!TAG ...]
  8. ##
  9. ## Description
  10. ##
  11. ## ACTION is one of 'chg', 'fix', 'new'
  12. ##
  13. ## Is WHAT the change is about.
  14. ##
  15. ## 'chg' is for refactor, small improvement, cosmetic changes...
  16. ## 'fix' is for bug fixes
  17. ## 'new' is for new features, big improvement
  18. ##
  19. ## AUDIENCE is optional and one of 'dev', 'usr', 'pkg', 'test', 'doc'
  20. ##
  21. ## Is WHO is concerned by the change.
  22. ##
  23. ## 'dev' is for developpers (API changes, refactors...)
  24. ## 'usr' is for final users (UI changes)
  25. ## 'pkg' is for packagers (packaging changes)
  26. ## 'test' is for testers (test only related changes)
  27. ## 'doc' is for doc guys (doc only changes)
  28. ##
  29. ## COMMIT_MSG is ... well ... the commit message itself.
  30. ##
  31. ## TAGs are additionnal adjective as 'refactor' 'minor' 'cosmetic'
  32. ##
  33. ## They are preceded with a '!' or a '@' (prefer the former, as the
  34. ## latter is wrongly interpreted in github.) Commonly used tags are:
  35. ##
  36. ## 'refactor' is obviously for refactoring code only
  37. ## 'minor' is for a very meaningless change (a typo, adding a comment)
  38. ## 'cosmetic' is for cosmetic driven change (re-indentation, 80-col...)
  39. ## 'wip' is for partial functionality but complete subfunctionality.
  40. ##
  41. ## Example:
  42. ##
  43. ## new: usr: support of bazaar implemented
  44. ## chg: re-indentend some lines !cosmetic
  45. ## new: dev: updated code to be compatible with last version of killer lib.
  46. ## fix: pkg: updated year of licence coverage.
  47. ## new: test: added a bunch of test around user usability of feature X.
  48. ## fix: typo in spelling my name in comment. !minor
  49. ##
  50. ## Please note that multi-line commit message are supported, and only the
  51. ## first line will be considered as the "summary" of the commit message. So
  52. ## tags, and other rules only applies to the summary. The body of the commit
  53. ## message will be displayed in the changelog without reformatting.
  54. ##
  55. ## ``ignore_regexps`` is a line of regexps
  56. ##
  57. ## Any commit having its full commit message matching any regexp listed here
  58. ## will be ignored and won't be reported in the changelog.
  59. ##
  60. ignore_regexps = [
  61. r'@minor', r'!minor',
  62. r'@cosmetic', r'!cosmetic',
  63. r'@refactor', r'!refactor',
  64. r'@wip', r'!wip',
  65. r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[p|P]kg:',
  66. r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[d|D]ev:',
  67. r'^(.{3,3}\s*:)?\s*[fF]irst commit.?\s*$',
  68. r'^$', ## ignore commits with empty messages
  69. ]
  70. ## ``section_regexps`` is a list of 2-tuples associating a string label and a
  71. ## list of regexp
  72. ##
  73. ## Commit messages will be classified in sections thanks to this. Section
  74. ## titles are the label, and a commit is classified under this section if any
  75. ## of the regexps associated is matching.
  76. ##
  77. ## Please note that ``section_regexps`` will only classify commits and won't
  78. ## make any changes to the contents. So you'll probably want to go check
  79. ## ``subject_process`` (or ``body_process``) to do some changes to the subject,
  80. ## whenever you are tweaking this variable.
  81. ##
  82. section_regexps = [
  83. ('New', [
  84. r'^[nN]ew\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
  85. ]),
  86. ('Changes', [
  87. r'^[cC]hg\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
  88. ]),
  89. ('Fix', [
  90. r'^[fF]ix\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
  91. ]),
  92. ('Other', None ## Match all lines
  93. ),
  94. ]
  95. ## ``body_process`` is a callable
  96. ##
  97. ## This callable will be given the original body and result will
  98. ## be used in the changelog.
  99. ##
  100. ## Available constructs are:
  101. ##
  102. ## - any python callable that take one txt argument and return txt argument.
  103. ##
  104. ## - ReSub(pattern, replacement): will apply regexp substitution.
  105. ##
  106. ## - Indent(chars=" "): will indent the text with the prefix
  107. ## Please remember that template engines gets also to modify the text and
  108. ## will usually indent themselves the text if needed.
  109. ##
  110. ## - Wrap(regexp=r"\n\n"): re-wrap text in separate paragraph to fill 80-Columns
  111. ##
  112. ## - noop: do nothing
  113. ##
  114. ## - ucfirst: ensure the first letter is uppercase.
  115. ## (usually used in the ``subject_process`` pipeline)
  116. ##
  117. ## - final_dot: ensure text finishes with a dot
  118. ## (usually used in the ``subject_process`` pipeline)
  119. ##
  120. ## - strip: remove any spaces before or after the content of the string
  121. ##
  122. ## - SetIfEmpty(msg="No commit message."): will set the text to
  123. ## whatever given ``msg`` if the current text is empty.
  124. ##
  125. ## Additionally, you can `pipe` the provided filters, for instance:
  126. #body_process = Wrap(regexp=r'\n(?=\w+\s*:)') | Indent(chars=" ")
  127. #body_process = Wrap(regexp=r'\n(?=\w+\s*:)')
  128. #body_process = noop
  129. body_process = ReSub(r'((^|\n)[A-Z]\w+(-\w+)*: .*(\n\s+.*)*)+$', r'') | strip
  130. ## ``subject_process`` is a callable
  131. ##
  132. ## This callable will be given the original subject and result will
  133. ## be used in the changelog.
  134. ##
  135. ## Available constructs are those listed in ``body_process`` doc.
  136. subject_process = (strip |
  137. ReSub(r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n@]*)(@[a-z]+\s+)*$', r'\4') |
  138. SetIfEmpty("No commit message.") | ucfirst | final_dot)
  139. ## ``tag_filter_regexp`` is a regexp
  140. ##
  141. ## Tags that will be used for the changelog must match this regexp.
  142. ##
  143. tag_filter_regexp = r'^[0-9]+\.[0-9]+(\.[0-9]+)?$'
  144. ## ``unreleased_version_label`` is a string or a callable that outputs a string
  145. ##
  146. ## This label will be used as the changelog Title of the last set of changes
  147. ## between last valid tag and HEAD if any.
  148. unreleased_version_label = "(unreleased)"
  149. ## ``output_engine`` is a callable
  150. ##
  151. ## This will change the output format of the generated changelog file
  152. ##
  153. ## Available choices are:
  154. ##
  155. ## - rest_py
  156. ##
  157. ## Legacy pure python engine, outputs ReSTructured text.
  158. ## This is the default.
  159. ##
  160. ## - mustache(<template_name>)
  161. ##
  162. ## Template name could be any of the available templates in
  163. ## ``templates/mustache/*.tpl``.
  164. ## Requires python package ``pystache``.
  165. ## Examples:
  166. ## - mustache("markdown")
  167. ## - mustache("restructuredtext")
  168. ##
  169. ## - makotemplate(<template_name>)
  170. ##
  171. ## Template name could be any of the available templates in
  172. ## ``templates/mako/*.tpl``.
  173. ## Requires python package ``mako``.
  174. ## Examples:
  175. ## - makotemplate("restructuredtext")
  176. ##
  177. #output_engine = rest_py
  178. #output_engine = mustache("restructuredtext")
  179. output_engine = mustache("markdown")
  180. #output_engine = makotemplate("restructuredtext")
  181. ## ``include_merge`` is a boolean
  182. ##
  183. ## This option tells git-log whether to include merge commits in the log.
  184. ## The default is to include them.
  185. include_merge = True
  186. ## ``log_encoding`` is a string identifier
  187. ##
  188. ## This option tells gitchangelog what encoding is outputed by ``git log``.
  189. ## The default is to be clever about it: it checks ``git config`` for
  190. ## ``i18n.logOutputEncoding``, and if not found will default to git's own
  191. ## default: ``utf-8``.
  192. #log_encoding = 'utf-8'
  193. ## ``publish`` is a callable
  194. ##
  195. ## Sets what ``gitchangelog`` should do with the output generated by
  196. ## the output engine. ``publish`` is a callable taking one argument
  197. ## that is an interator on lines from the output engine.
  198. ##
  199. ## Some helper callable are provided:
  200. ##
  201. ## Available choices are:
  202. ##
  203. ## - stdout
  204. ##
  205. ## Outputs directly to standard output
  206. ## (This is the default)
  207. ##
  208. ## - FileInsertAtFirstRegexMatch(file, pattern, idx=lamda m: m.start())
  209. ##
  210. ## Creates a callable that will parse given file for the given
  211. ## regex pattern and will insert the output in the file.
  212. ## ``idx`` is a callable that receive the matching object and
  213. ## must return a integer index point where to insert the
  214. ## the output in the file. Default is to return the position of
  215. ## the start of the matched string.
  216. ##
  217. ## - FileRegexSubst(file, pattern, replace, flags)
  218. ##
  219. ## Apply a replace inplace in the given file. Your regex pattern must
  220. ## take care of everything and might be more complex. Check the README
  221. ## for a complete copy-pastable example.
  222. ##
  223. # publish = FileInsertIntoFirstRegexMatch(
  224. # "CHANGELOG.rst",
  225. # r'/(?P<rev>[0-9]+\.[0-9]+(\.[0-9]+)?)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n/',
  226. # idx=lambda m: m.start(1)
  227. # )
  228. #publish = stdout
  229. ## ``revs`` is a list of callable or a list of string
  230. ##
  231. ## callable will be called to resolve as strings and allow dynamical
  232. ## computation of these. The result will be used as revisions for
  233. ## gitchangelog (as if directly stated on the command line). This allows
  234. ## to filter exaclty which commits will be read by gitchangelog.
  235. ##
  236. ## To get a full documentation on the format of these strings, please
  237. ## refer to the ``git rev-list`` arguments. There are many examples.
  238. ##
  239. ## Using callables is especially useful, for instance, if you
  240. ## are using gitchangelog to generate incrementally your changelog.
  241. ##
  242. ## Some helpers are provided, you can use them::
  243. ##
  244. ## - FileFirstRegexMatch(file, pattern): will return a callable that will
  245. ## return the first string match for the given pattern in the given file.
  246. ## If you use named sub-patterns in your regex pattern, it'll output only
  247. ## the string matching the regex pattern named "rev".
  248. ##
  249. ## - Caret(rev): will return the rev prefixed by a "^", which is a
  250. ## way to remove the given revision and all its ancestor.
  251. ##
  252. ## Please note that if you provide a rev-list on the command line, it'll
  253. ## replace this value (which will then be ignored).
  254. ##
  255. ## If empty, then ``gitchangelog`` will act as it had to generate a full
  256. ## changelog.
  257. ##
  258. ## The default is to use all commits to make the changelog.
  259. #revs = ["^1.0.3", ]
  260. #revs = [
  261. # Caret(
  262. # FileFirstRegexMatch(
  263. # "CHANGELOG.rst",
  264. # r"(?P<rev>[0-9]+\.[0-9]+(\.[0-9]+)?)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n")),
  265. # "HEAD"
  266. #]
  267. revs = []