在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:vaab/gitchangelog开源软件地址:https://github.com/vaab/gitchangelog开源编程语言:Python 92.1%开源软件介绍:gitchangelogUse your commit log to make beautifull and configurable changelog file. Feature
Requirements
Please submit an issue if you encounter incompatibilities. Installationfull packageGitchangelog is published on PyPI, thus: pip install gitchangelog .. is the way to go for install the full package on any platform. If you are installing from source, please note that the development tools are not working fully yet on Windows. The full package provides the
from sourceIf you'd rather work from the source repository, it supports the common idiom to install it on your system: python setup.py install Note that for linux/BSD, there's a link to the executable in the root of the source. This can be a convenient way to work on the source version. single executable installationThe file curl -sSL https://raw.githubusercontent.com/vaab/gitchangelog/master/src/gitchangelog/gitchangelog.py > /usr/local/bin/gitchangelog && chmod +x /usr/local/bin/gitchangelog It'll install Please note: if you choose to install it in this standalone mode, then you must make sure to value at least all the required configuration keys in your config file. As a good start you should probably copy the reference configuration file as you base configuration file. This is due to the fact that SampleThe default output is ReSTructured text, so it should be readable in ASCII. Here is a small sample of the Current * 59f902a Valentin Lab new: dev: sections in changelog are now in the order given in ``gitchangelog.rc`` in the ``section_regexps`` option. (0.1.2) * c6f72cc Valentin Lab chg: dev: commented code to toggle doctest mode. * a9c38f3 Valentin Lab fix: dev: doctests were failing on this. * 59524e6 Valentin Lab new: usr: added ``body_split_regexp`` option to attempts to format correctly body of commit. * 5883f07 Valentin Lab new: usr: use a list of tuple instead of a dict for ``section_regexps`` to be able to manage order between section on find match. * 7c1d480 Valentin Lab new: dev: new ``unreleased_version_label`` option in ``gitchangelog.rc`` to change label of not yet released code. * cf29c9c Valentin Lab fix: dev: bad sorting of tags (alphanumerical). Changed to commit date sort. * 61d8f80 Valentin Lab fix: dev: support of empty commit message. * eeca31b Valentin Lab new: dev: use ``gitchangelog`` section in ``git config`` world appropriately. * 6142b71 Valentin Lab chg: dev: cosmetic removal of trailing whitespaces * 3c3edd5 Valentin Lab fix: usr: ``git`` in later versions seems to fail on ``git config <key>`` with errlvl 255, that was not supported. * 3f9617d Valentin Lab fix: usr: removed Traceback when there were no tags at all in the current git repository. * e0db9ae Valentin Lab new: usr: added section classifiers (ie: New, Change, Bugs) and updated the sample rc file. (0.1.1) * 0c66d59 Valentin Lab fix: dev: Fixed case where exception was thrown if two tags are on the same commit. * d2fae0d Valentin Lab new: usr: added a succint ``--help`` support. And here is the 0.1.2 (2011-05-17) ------------------ New ~~~ - Sections in changelog are now in the order given in ``git- changelog.rc`` in the ``section_regexps`` option. [Valentin Lab] - Added ``body_split_regexp`` option to attempts to format correctly body of commit. [Valentin Lab] - Use a list of tuple instead of a dict for ``section_regexps`` to be able to manage order between section on find match. [Valentin Lab] - New ``unreleased_version_label`` option in ``gitchangelog.rc`` to change label of not yet released code. [Valentin Lab] - Use ``gitchangelog`` section in ``git config`` world appropriately. [Valentin Lab] Changes ~~~~~~~ - Commented code to toggle doctest mode. [Valentin Lab] - Cosmetic removal of trailing whitespaces. [Valentin Lab] Fix ~~~ - Doctests were failing on this. [Valentin Lab] - Bad sorting of tags (alphanumerical). Changed to commit date sort. [Valentin Lab] - Support of empty commit message. [Valentin Lab] - ``git`` in later versions seems to fail on ``git config <key>`` with errlvl 255, that was not supported. [Valentin Lab] - Removed Traceback when there were no tags at all in the current git repository. [Valentin Lab] 0.1.1 (2011-04-07) ------------------ New ~~~ - Added section classifiers (ie: New, Change, Bugs) and updated the sample rc file. [Valentin Lab] - Added a succint ``--help`` support. [Valentin Lab] Fix ~~~ - Fixed case where exception was thrown if two tags are on the same commit. [Valentin Lab] And the rendered full result is directly used to generate the HTML webpage of the changelog of the PyPI page. UsageThe reference configuration file is delivered within
The recommended location for
Then, you'll be able to call Configuration file formatThe reference configuration file is quite heavily commented and is quite simple. You should be able to use it as required. The changelog of gitchangelog is generated with himself and with the reference configuration file. You'll see the output in the changelog of the PyPI page. Output EnginesAt the end of the configuration file, you'll notice a variable called
To render the template, As people might have different needs and knowledge, a templating
system using A MustacheThe The mustache templates are powered via pystache the python implementation of the mustache specifications. So mustache output engine will only be available if you have pystache module available in your python environment. There are mustache templates bundled with the default installation
of gitchangelog. These can be called by providing a simple label to the
output_engine = mustache("markdown") Or you could provide your own mustache template by specifying an
absolute path (or a relative one, starting from the git toplevel of
your project by default, or if set, the
output_engine = mustache(".gitchangelog.tpl") And feel free to copy the bundled templates to use them as bases for
your own variations. In the source code, these are located in
MakoThe There are mako templates bundled with the default installation
of gitchangelog. These can be called by providing a simple label to the
output_engine = makotemplate("markdown") Or you could provide your own mustache template by specifying an
absolute path (or a relative one, starting from the git toplevel of
your project by default, or if set, the
output_engine = makotemplate(".gitchangelog.tpl") And feel free to copy the bundled templates to use them as bases for
your own variations. In the source code, these are located in
Changelog data treeThis is a sample of the current data structure sent to output engines: {'title': 'Changelog', 'versions': [{'label': '%%version%% (unreleased)', 'date': None, 'tag': None 'sections': [{'label': 'Changes', 'commits': [{'author': 'John doe', 'body': '', 'subject': 'Adding some extra values.'}, {'author': 'John Doe', 'body': '', 'subject': 'Some more changes'}]}, {'label': 'Other', 'commits': [{'author': 'Jim Foo', 'body': '', 'subject': 'classic modification'}, {'author': 'Jane Done', 'body': '', 'subject': 'Adding some stuff to do.'}]}]}, {'label': 'v0.2.5 (2013-08-06)', 'date': '2013-08-06', 'tag': 'v0.2.5' 'sections': [{'commits': [{'author': 'John Doe', 'body': '', 'subject': 'Updating Changelog installation.'}], 'label': 'Changes'}]}]} Merged branches history supportCommit attribution to a specific version could be tricky. Suppose you have this typical merge tree (spot the tags!): * new: something (HEAD, tag: 0.2, develop) * Merge tag '0.1.1' into develop |\ | * fix: out-of-band hotfix (tag: 0.1.1) * | chg: continued development |/ * fix: something (tag: 0.1) * first commit (tag: 0.0.1, master) Here's a minimal draft of gitchangelog to show how commit are attributed to versions: 0.2 * new: something. * Merge tag '0.1.1' into develop. * chg: continued development. 0.1.1 * fix: out-of-band hotfix. 0.1 * fix: something. Note you can remove automatically all merge commit from
gitchangelog output by using Use casesNo sectionningIf you want to remove sectionning but keep anything else, you should probably use: section_regexps = [ ('', None) ] subject_process = (strip | ucfirst | final_dot) This will disable sectionning and won't remove the prefixes used for sectionning from the commit's summary. Incremental changelogAlso known as partial changelog generation, this feature allows to generate only a subpart of your changelog, and combined with configurable publishing actions, you can insert the result inside an existing changelog. Usually this makes sense:
Generating partial changelog is as simple as ## will output only tags between 0.0.2 (excluded) and 0.0.3 (included) gitchangelog 0.0.2..0.0.3 ## will output only tags since 0.0.3 (excluded) gitchangelog ^0.0.3 HEAD ## will output all tags up to 0.0.3 (included) gitchangelog 0.0.3 Additionally, Here is an example that fits the current changelog format: revs = [ Caret( FileFirstRegexMatch( "CHANGELOG.rst", r"(?P<rev>[0-9]+\.[0-9]+(\.[0-9]+))\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n")), ] This will look into the file Note that the data structure provided to the template will set the
By default, this will only output to standard output the new sections
of your changelog, you might want to insert it directly in your existing
changelog. This is where publish = FileInsertIntoFirstRegexMatch( "CHANGELOG.rst", r'/(?P<rev>[0-9]+\.[0-9]+(\.[0-9]+)?)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n/', idx=lambda m: m.start(1) ) The full recipe could be: OUTPUT_FILE = "CHANGELOG.rst" INSERT_POINT = r"\b(?P<rev>[0-9]+\.[0-9]+)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n" revs = [ Caret(FileFirstRegexMatch(OUTPUT_FILE, INSERT_POINT)), "HEAD" ] action = FileInsertAtFirstRegexMatch( OUTPUT_FILE, INSERT_POINT, idx=lambda m: m.start(1) ) Alternatively, you can use this other recipe, using OUTPUT_FILE = "CHANGELOG.rst" INSERT_POINT_REGEX = r'''(?isxu) ^ ( \s*Changelog\s*(\n|\r\n|\r) ## ``Changelog`` line ==+\s*(\n|\r\n|\r){2} ## ``=========`` rest underline ) ( ## Match all between changelog and release rev ( (?! (?<=(\n|\r)) ## look back for newline %(rev)s ## revision \s+ \([0-9]+-[0-9]{2}-[0-9]{2}\)(\n|\r\n|\r) ## date --+(\n|\r\n|\r) ## ``---`` underline ) . )* ) (?P<rev>%(rev)s) ''' % {'rev': r"[0-9]+\.[0-9]+(\.[0-9]+)?"} revs = [ Caret(FileFirstRegexMatch(OUTPUT_FILE, INSERT_POINT_REGEX)), "HEAD" ] publish = FileRegexSubst(OUTPUT_FILE, INSERT_POINT_REGEX, r"\1\o\g<rev>") As a second example, here is the same recipe for mustache markdown format: OUTPUT_FILE = "CHANGELOG.rst" INSERT_POINT_REGEX = r'''(?isxu) ^ ( \s*\#\s+Changelog\s*(\n|\r\n|\r) ## ``Changelog`` line ) ( ## Match all between changelog and release rev ( (?! (?<=(\n|\r)) ## look back for newline \#\#\s+%(rev)s ## revision \s+ \([0-9]+-[0-9]{2}-[0-9]{2}\)(\n|\r\n|\r) ## date ) . )* ) (?P<tail>\#\#\s+(?P<rev>%(rev)s)) ''' % {'rev': r"[0-9]+\.[0-9]+(\.[0-9]+)?"} revs = [ Caret(FileFirstRegexMatch(OUTPUT_FILE, INSERT_POINT_REGEX)), "HEAD" ] publish = FileRegexSubst(OUTPUT_FILE, INSERT_POINT_REGEX, r"\1\o\n\g<tail>") ContributingAny suggestion or issue is welcome. Push request are very welcome, please check out the guidelines. Push Request GuidelinesYou can send any code. I'll look at it and will integrate it myself in the code base while leaving you as the commit(s) author. This process can take time and it'll take less time if you follow the following guidelines:
If you have some questions about guidelines which is not answered here,
please check the current LicenseCopyright (c) 2012-2018 Valentin Lab. Licensed under the BSD License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论