Package: mkchangelog
mkchangelogCI/CDPackageMetaThe CHANGELOG.md generator from git log using theconventional commitsscheme.Example generated changelog:CHANGELOG.mdTable of ContentsInstallationUsageConfigurationFeaturesLicenseInstallationpip install mkchangelogUsageThe list of versions is taken from list of signed git tags detected by prefix (defaultv, f.e.v1.3.4).Generate changelogTo generate changelog for current and all previous versions (signed tags) to CHAGELOG.md (default):$mkchangeloggenerate# Creates CHANGELOG.md$mkchangelogg# Creates CHANGELOG.md$mkchangelogg--stdout# Prints changelog to stdout$mkchangelogg--help# Prints help for generate commandGenerate commit message$mkchangelogcommit# Generates message.txt$mkchangelogc# Generates message.txt$gitcommit-Fmessage.txt# Use message.txt as commit messageBump versionInteractive tool to:generate changelogcalculate next version from feat/fix/breaking changes commitscommit changelog and tag version$mkchangelogbump# Bumps next version$mkchangelogb# Bumps next versionManage configurationYou can change default configuration using.mkchangelog(ini format) file in current directory.$mkchangelogsettings# Shows current config as jon$mkchangelogs# Shows current config as jon$mkchangelogs--generate# Prints default config ini fileConfigurationDefault configuration is:[GENERAL]output=CHANGELOG.md; output filetemplate=markdown; template to usecommit_limit=100; commits limit per release (version)unreleased=False; include unreleased changes (HEAD...last_version)unreleased_version=Unreleased; title of unreleased changes (f.e. next version v3.0.0)hide_empty_releases=False; hide releases with no gathered commitschangelog_title=Changelog; Changelog titlecommit_types_list=fix,feat; list of commit types to include in Changelogcommit_type_default_priority=10; default priority of commit type, for Changelog orderingtag_prefix=v; versions tag prefix to detect/generate git tags[commit_types]                          ; valid commit types (for `--commit-types all`) and their namesbuild=Buildchore=Choreci=CIdev=Devdocs=Docsfeat=Featuresfix=Fixesperf=Performancerefactor=Refactorsstyle=Styletest=Testtranslations=Translations[commit_types_priorities]               ; custom commit types priorities, for Changelog orderingfeat=40fix=30refactor=20FeaturesCreates changelog from git logthe list of releases is created from list of annotated git tags matching configuredtag_prefix.the unreleased changes are included ifunreleasedistrue.from git log messages matching configuredcommit_typesare parsed and grouped by the type.certain groups (types) are sorted by configuredcommit_types_priorities.only configuredcommit_types_listtypes are rendered, if not--commit-types [type,type, | all]was providedIncludes additional git commits from text filesadditional commit files (*.txt) can be put at.mkchangelog.d/versions/<version>/commits/directoryFor example:v1.0.3/commitsBuilt-in templatesThemkchangelogincludes a few builtin changelog output formats$mkchangelogg--templatemarkdown$mkchangelogg--templaterst$mkchangelogg--templatejsonCustomheaderandfooterper version [for built-in templates]Theheaderandfooterfiles are included from files:.mkchangelog.d/versions//header.mkchangelog.d/versions//footerFor example:v1.0.3/headerv1.0.3/footerCustomjinjatemplatesYou can create your own templates and pass them by--templateparameter ofmkchangelog generateor set it in.mkchangelogconfiguration file.Using configuration file[GENERAL]...# put `custom_template.jinja` in `.mkchangelog.d/templates/template=custom_template.jinja# or specify full path to templatetemplate=./path/to/template.jinja...Using--templateparameter*#put`custom_template.jinja`in`.mkchangelog.d/templates/$mkchangelogg--templatecustom_template.jinja#orspecifyfullpathtotemplate$mkchangelogg--template./path/to/template.jinjaRefer to built-in templates for examples:markdown.jinja2rst.jinja2Template filtersApart from builtin jinja2 filter there are additional custom filters:underline- f.e.{{ changelog.title | underline('=') }}regex_replace- f.e.{{ "line with #12 issue ref" | regex_replace("#(\d+)", "#ISSUE-\\1") }}You can create and register your own filters using.mkchangelog.d/hooks.pyfile.Example implementation of hooks:https://github.com/onjin/mkchangelog/blob/master/.mkchangelog.d/hooks.pyYour own commit typesThecommit_typescan be fully customized by.mkchangelogfile.[GENERAL]commit_types_list=awesomehide_empty_releases=True[commit_types]awesome=Best changesad=Had to write itnot_sure=Works but why?[commit_types_priorities]awesome=40sad=30not_sure=20$mkchangelogg--commit_typesall$mdlessCHANGELOG.mdPlugins / hooks systemYou can use hooks system to extend mkchangelog functionality.
All hooks are loaded from.mkchangelog.d/hooks.pyfile which must be a valid python module.You can check the specification for available hooks athookspecs.pyfile.
The mkchangelog built-in hooks are implemented atlib.pyfile.Available hooks:provide_template_filters - returns dictionary of jinja2 filters,provide_changelog_loglines_filter - returns functions which filters list ofLogLine- you can use it to filter out f.e. some scopesExample .mkchangelog.d/hooks.pyfrom__future__importannotationsimportrandomfromtypingimportAny,Callable,Dict,Listfrommkchangelog.configimportSettingsfrommkchangelog.libimporthookimpldeffancylize(s):return"".join([c.lower()ifrandom.randint(0,1)elsec.upper()forcins])@hookimpldefprovide_template_filters(settings:Settings)->Dict[str,Callable[[Any],str]]:# noqa"""Add 'fancylize' jinja2 template filter"""return{"fancylize":fancylize}@hookimpldefprovide_changelog_loglines_filter(settings:Settings)->Callable[[List[LogLine]],List[LogLine]]:"""Hide lines with scope 'hidden_scope'"""returnlambdaloglines:[lineforlineinloglinesifline.scope!="hidden_scope"]ContributingInstallpre-commitpipinstallpre-commitpre-commitinstallRun testshatch run all:testLintinghatch run lint:allLicensemkchangelogis distributed under the terms of theMITlicense.