From ec3cdb605fff9a2477113512e551c6f25bb41376 Mon Sep 17 00:00:00 2001 From: Niels Abspoel Date: Sat, 16 Feb 2019 14:27:11 +0100 Subject: [PATCH] add changelog generator --- .gitchangelog.rc | 289 +++++++++++++++++++++++++++++++++++++++++++++++ CHANGELOG.rst | 236 ++++++++++++++++++++++++++------------ README.rst | 10 ++ 3 files changed, 462 insertions(+), 73 deletions(-) create mode 100644 .gitchangelog.rc diff --git a/.gitchangelog.rc b/.gitchangelog.rc new file mode 100644 index 00000000..0c1c7f4d --- /dev/null +++ b/.gitchangelog.rc @@ -0,0 +1,289 @@ +# -*- coding: utf-8; mode: python -*- +## +## Format +## +## ACTION: [AUDIENCE:] COMMIT_MSG [!TAG ...] +## +## Description +## +## ACTION is one of 'chg', 'fix', 'new' +## +## Is WHAT the change is about. +## +## 'chg' is for refactor, small improvement, cosmetic changes... +## 'fix' is for bug fixes +## 'new' is for new features, big improvement +## +## AUDIENCE is optional and one of 'dev', 'usr', 'pkg', 'test', 'doc' +## +## Is WHO is concerned by the change. +## +## 'dev' is for developpers (API changes, refactors...) +## 'usr' is for final users (UI changes) +## 'pkg' is for packagers (packaging changes) +## 'test' is for testers (test only related changes) +## 'doc' is for doc guys (doc only changes) +## +## COMMIT_MSG is ... well ... the commit message itself. +## +## TAGs are additionnal adjective as 'refactor' 'minor' 'cosmetic' +## +## They are preceded with a '!' or a '@' (prefer the former, as the +## latter is wrongly interpreted in github.) Commonly used tags are: +## +## 'refactor' is obviously for refactoring code only +## 'minor' is for a very meaningless change (a typo, adding a comment) +## 'cosmetic' is for cosmetic driven change (re-indentation, 80-col...) +## 'wip' is for partial functionality but complete subfunctionality. +## +## Example: +## +## new: usr: support of bazaar implemented +## chg: re-indentend some lines !cosmetic +## new: dev: updated code to be compatible with last version of killer lib. +## fix: pkg: updated year of licence coverage. +## new: test: added a bunch of test around user usability of feature X. +## fix: typo in spelling my name in comment. !minor +## +## Please note that multi-line commit message are supported, and only the +## first line will be considered as the "summary" of the commit message. So +## tags, and other rules only applies to the summary. The body of the commit +## message will be displayed in the changelog without reformatting. + + +## +## ``ignore_regexps`` is a line of regexps +## +## Any commit having its full commit message matching any regexp listed here +## will be ignored and won't be reported in the changelog. +## +ignore_regexps = [ + r'@minor', r'!minor', + r'@cosmetic', r'!cosmetic', + r'@refactor', r'!refactor', + r'@wip', r'!wip', + r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[p|P]kg:', + r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[d|D]ev:', + r'^(.{3,3}\s*:)?\s*[fF]irst commit.?\s*$', + r'^$', ## ignore commits with empty messages +] + + +## ``section_regexps`` is a list of 2-tuples associating a string label and a +## list of regexp +## +## Commit messages will be classified in sections thanks to this. Section +## titles are the label, and a commit is classified under this section if any +## of the regexps associated is matching. +## +## Please note that ``section_regexps`` will only classify commits and won't +## make any changes to the contents. So you'll probably want to go check +## ``subject_process`` (or ``body_process``) to do some changes to the subject, +## whenever you are tweaking this variable. +## +section_regexps = [ + ('New', [ + r'^[nN]ew\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$', + ]), + ('Changes', [ + r'^[cC]hg\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$', + ]), + ('Fix', [ + r'^[fF]ix\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$', + ]), + + ('Other', None ## Match all lines + ), + +] + + +## ``body_process`` is a callable +## +## This callable will be given the original body and result will +## be used in the changelog. +## +## Available constructs are: +## +## - any python callable that take one txt argument and return txt argument. +## +## - ReSub(pattern, replacement): will apply regexp substitution. +## +## - Indent(chars=" "): will indent the text with the prefix +## Please remember that template engines gets also to modify the text and +## will usually indent themselves the text if needed. +## +## - Wrap(regexp=r"\n\n"): re-wrap text in separate paragraph to fill 80-Columns +## +## - noop: do nothing +## +## - ucfirst: ensure the first letter is uppercase. +## (usually used in the ``subject_process`` pipeline) +## +## - final_dot: ensure text finishes with a dot +## (usually used in the ``subject_process`` pipeline) +## +## - strip: remove any spaces before or after the content of the string +## +## - SetIfEmpty(msg="No commit message."): will set the text to +## whatever given ``msg`` if the current text is empty. +## +## Additionally, you can `pipe` the provided filters, for instance: +#body_process = Wrap(regexp=r'\n(?=\w+\s*:)') | Indent(chars=" ") +#body_process = Wrap(regexp=r'\n(?=\w+\s*:)') +#body_process = noop +body_process = ReSub(r'((^|\n)[A-Z]\w+(-\w+)*: .*(\n\s+.*)*)+$', r'') | strip + + +## ``subject_process`` is a callable +## +## This callable will be given the original subject and result will +## be used in the changelog. +## +## Available constructs are those listed in ``body_process`` doc. +subject_process = (strip | + ReSub(r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n@]*)(@[a-z]+\s+)*$', r'\4') | + SetIfEmpty("No commit message.") | ucfirst | final_dot) + + +## ``tag_filter_regexp`` is a regexp +## +## Tags that will be used for the changelog must match this regexp. +## +tag_filter_regexp = r'^v[0-9]+\.[0-9]+(\.[0-9]+)?$' + + +## ``unreleased_version_label`` is a string or a callable that outputs a string +## +## This label will be used as the changelog Title of the last set of changes +## between last valid tag and HEAD if any. +unreleased_version_label = "(unreleased)" + + +## ``output_engine`` is a callable +## +## This will change the output format of the generated changelog file +## +## Available choices are: +## +## - rest_py +## +## Legacy pure python engine, outputs ReSTructured text. +## This is the default. +## +## - mustache() +## +## Template name could be any of the available templates in +## ``templates/mustache/*.tpl``. +## Requires python package ``pystache``. +## Examples: +## - mustache("markdown") +## - mustache("restructuredtext") +## +## - makotemplate() +## +## Template name could be any of the available templates in +## ``templates/mako/*.tpl``. +## Requires python package ``mako``. +## Examples: +## - makotemplate("restructuredtext") +## +output_engine = rest_py +#output_engine = mustache("restructuredtext") +#output_engine = mustache("markdown") +#output_engine = makotemplate("restructuredtext") + + +## ``include_merge`` is a boolean +## +## This option tells git-log whether to include merge commits in the log. +## The default is to include them. +include_merge = False + + +## ``log_encoding`` is a string identifier +## +## This option tells gitchangelog what encoding is outputed by ``git log``. +## The default is to be clever about it: it checks ``git config`` for +## ``i18n.logOutputEncoding``, and if not found will default to git's own +## default: ``utf-8``. +log_encoding = 'utf-8' + + +## ``publish`` is a callable +## +## Sets what ``gitchangelog`` should do with the output generated by +## the output engine. ``publish`` is a callable taking one argument +## that is an interator on lines from the output engine. +## +## Some helper callable are provided: +## +## Available choices are: +## +## - stdout +## +## Outputs directly to standard output +## (This is the default) +## +## - FileInsertAtFirstRegexMatch(file, pattern, idx=lamda m: m.start()) +## +## Creates a callable that will parse given file for the given +## regex pattern and will insert the output in the file. +## ``idx`` is a callable that receive the matching object and +## must return a integer index point where to insert the +## the output in the file. Default is to return the position of +## the start of the matched string. +## +## - FileRegexSubst(file, pattern, replace, flags) +## +## Apply a replace inplace in the given file. Your regex pattern must +## take care of everything and might be more complex. Check the README +## for a complete copy-pastable example. +## +# publish = FileInsertIntoFirstRegexMatch( +# "CHANGELOG.rst", +# r'/(?P[0-9]+\.[0-9]+(\.[0-9]+)?)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n/', +# idx=lambda m: m.start(1) +# ) +publish = stdout + + +## ``revs`` is a list of callable or a list of string +## +## callable will be called to resolve as strings and allow dynamical +## computation of these. The result will be used as revisions for +## gitchangelog (as if directly stated on the command line). This allows +## to filter exaclty which commits will be read by gitchangelog. +## +## To get a full documentation on the format of these strings, please +## refer to the ``git rev-list`` arguments. There are many examples. +## +## Using callables is especially useful, for instance, if you +## are using gitchangelog to generate incrementally your changelog. +## +## Some helpers are provided, you can use them:: +## +## - FileFirstRegexMatch(file, pattern): will return a callable that will +## return the first string match for the given pattern in the given file. +## If you use named sub-patterns in your regex pattern, it'll output only +## the string matching the regex pattern named "rev". +## +## - Caret(rev): will return the rev prefixed by a "^", which is a +## way to remove the given revision and all its ancestor. +## +## Please note that if you provide a rev-list on the command line, it'll +## replace this value (which will then be ignored). +## +## If empty, then ``gitchangelog`` will act as it had to generate a full +## changelog. +## +## The default is to use all commits to make the changelog. +#revs = ["^1.0.3", ] +#revs = [ +# Caret( +# FileFirstRegexMatch( +# "CHANGELOG.rst", +# r"(?P[0-9]+\.[0-9]+(\.[0-9]+)?)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n")), +# "HEAD" +#] +revs = [] diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3f9d58c3..7d5ebc7a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,73 +1,163 @@ -template formula -================ - -0.1.5 (2019-02-15) - -- Fix missing ')' in TOFS example - -0.1.4 (2019-02-15) - -- Remove obsolete VERSION file -- Add FORMULA file -- Update osfamilymap.yaml, osmap.yaml & osfingermap.yaml - -0.1.3 (2019-02-12) - -- Use grains.filter_by instead of defaults.merge in map.jinja -- Add osfingermap.yaml -- Add tags and update VERSION and CHANGELOG - -0.1.2 (2019-02-12) - -- Update map.jinja, osfamilymap.yaml & osmap.yaml - -0.1.1 (2019-02-10) - -- Update map.jinja and README -- Add tags and update VERSION and CHANGELOG - -0.1.0 (2019-02-08) - -- Update formula with TOFS pattern - -0.0.9 (2018-12-11) - -- Add Version File - -0.0.8 (2018-03-02) - -- Align with Saltstack Official Documenation - -0.0.7 (2017-06-18) - -- Fix typos and comments - -0.0.6 (2015-07-1) - -- Improve style and jinja to match salt-Formula - -0.0.5 (2014-07-28) - -- Fixed broken link to Salt Formula documentation - - -0.0.4 (2014-02-26) - -- Add CHANGELOG.rst - - -0.0.3 (2014-02-17) - -- Add map.jinja -- Use map.jinja content in init.sls - - -0.0.2 (2014-02-16) - -- Better README extension changed from .md to .rst -- Add link to Salt Formula documentation - - -0.0.1 (2013-11-03) - -- Initial version +Changelog +========= + + +v0.1.5 (2019-02-15) +------------------- +- Prepare `v0.1.5` [Imran Iqbal] +- Fix missing ')' [gmazrael] + + +v0.1.4 (2019-02-15) +------------------- +- Replace obsolete `VERSION` file and replace with `FORMULA` file. + [Imran Iqbal] + + +v0.1.3 (2019-02-12) +------------------- +- Updated changelog and version. [Alexander Weidinger] +- Map.jinja: use grains.filter_by instead of defaults.merge. [Alexander + Weidinger] + + because defaults.merge does not work with salt-ssh. + https://github.com/saltstack/salt/issues/51605 + + Added osfingermap.yaml. + + +v0.1.2 (2019-02-12) +------------------- +- Improve comments and examples in `osfamilymap` & `osmap` [Imran Iqbal] +- Fix `map.jinja` and add more OSes. [Imran Iqbal] + + +v0.1.1 (2019-02-10) +------------------- +- Update. [Niels Abspoel] +- Update formula with map.jinja and style guide references, improve + README and VERSION. [Niels Abspoel] + + +v0.1.0 (2019-02-10) +------------------- +- Examples must be consistent. [Daniel Dehennin] + + The “template” is kept during rendering. + + * TOFS_pattern.md: add “template” to rendered state. + + * template/macros.jinja: ditoo. +- Remove double slash in generated salt URL. [Daniel Dehennin] + + When the files are “full path” with leading slash “/”, the generated + URL contain a double slash because of the join. + + * template/macros.jinja: remove leading slash before joining parts. + + * TOFS_pattern.md: mirror changes of “macros.jinja”. +- Add an example for “ntp” of the use of “files_switch” [Daniel + Dehennin] +- Accept pillar separator in “files_switch” prefix. [Daniel Dehennin] + + The prefix was used for 2 purposes: + + - define the pillar prefix where to lookup “:files_switch”. It + supports the colon “:” separator to lookup in pillar subtree like + “foo:bar” + - define the path prefix where to look for “files/”, It did not support + separator to lookup inside directory tree. + + This patch only replace any colon “:” with “/” when looking up + “files/” directory, with the “foo:bar” prefix: + + - lookup “foo:bar:files_switch” pillar to get list of grains to match + - lookup files under “salt://foo/bar/files/” + + * TOFS_pattern.md: document the new use of “prefix” supporting colon “:”. + + * template/macros.jinja: transform any colon “:” in “prefix” by slash + “/” to lookup files. +- Make TOFS pattern example usable. [Daniel Dehennin] + + The example could not be used as-is. This commit improve conformity to + formula conventions. + + * TOFS_pattern.md: add missing commas “,” in “map.jinja” and extra one + to ease the addition of new entries. + Import “map.jinja” in “init.sls” and “conf.sls”. + Declare descriptive state IDs. + Use the “module.function” notation. + Use the “name” parameter. +- Cosmetics modification of TOFS pattern documentation. [Daniel + Dehennin] + + * TOFS_pattern.md: add myself as modifier. + Trim trailing whitespaces. + Separate titles from first paragraph. +- Switch template.config to TOFS pattern. [Daniel Dehennin] +- Import TOFS pattern from Zabbix formula. [Daniel Dehennin] + + +v0.0.9 (2019-02-10) +------------------- +- Add VERSION file. [Karim Hamza] +- Add note about formula versioning. [Karim Hamza] + + +v0.0.8 (2019-02-10) +------------------- +- Align with SaltStack official formulas doc page. [Denys Havrysh] +- Use https in the link to SaltStack documentation. [Denys Havrysh] + + +v0.0.7 (2019-02-10) +------------------- +- Map.ninja: fix typos and leftover comments. [Marco Molteni] +- Remove whitespace in map.jinja comment. [Andrew Gabbitas] + + +v0.0.6 (2019-02-10) +------------------- +- Improve style and jinja too match salt-formula. [Niels Abspoel] +- Propose new-ish formula style - defaults live in defaults.yml - map + jinja overrides by grain + merges pillar:lookup - split all + contextually similar states in their own files. [puneet kandhari] + + +v0.0.5 (2019-02-10) +------------------- +- Change states to use short-dec style. [Seth House] +- Update CHANGELOG.rst. [Nitin Madhok] +- Update README.rst. [Nitin Madhok] + + Fix broken link +- Fixing pillar to match the map file. [Forrest] + + Map file and pillar didn't match. + + +v0.0.4 (2019-02-10) +------------------- +- Add change log. [Antti Jokipii] + + +v0.0.3 (2019-02-10) +------------------- +- Updated the license and readme to match our standards. [Forrest + Alvarez] +- Use map.jinja content in init.sls. [Eugene Vereschagin] +- Add map.jinja. [Eugene Vereschagin] + + +v0.0.2 (2019-02-10) +------------------- +- Add link to Salt Formula documentation. [Eugene Vereschagin] +- Change extension from .md to .rst. [Eugene Vereschagin] + + +v0.0.1 (2019-02-10) +------------------- +- Initial commit. [Lukas Erlacher] + + diff --git a/README.rst b/README.rst index c6574845..b362fcfc 100644 --- a/README.rst +++ b/README.rst @@ -18,6 +18,16 @@ wich contains the currently released version. Formula is versioned according to See `Formula Versioning Section `_ for more details. +Changelog +========= + +To generate a changelog there is an included .gitchangelog.rc file which +corresponds with `gitchangelog`_ + + gitchangelog > CHANGELOG.rst + + + Available states ================