Skip to content

Commit 6178d2d

Browse files
committed
Added diff linking and bump2version docs.
1 parent af237cd commit 6178d2d

2 files changed

Lines changed: 73 additions & 9 deletions

File tree

docsrc/recipes/index.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All regular expression actions have the following boolean parameters:
1111
- [dotall_flag](https://docs.python.org/3/library/re.html#re.DOTALL)
1212
- [verbose_flag](https://docs.python.org/3/library/re.html#re.VERBOSE)
1313

14-
For example, this sets the multi-line flag and the ignore case flag:
14+
For example, this sets the `multiline_flag` and the `ignorecase_flag`:
1515

1616
```yaml
1717
- action: FirstRegExMatch
@@ -24,7 +24,7 @@ For example, this sets the multi-line flag and the ignore case flag:
2424
2525
You can also use inline notation `(?<flags>)` where `<flags>` is one or more of `a` (ASCII), `i` (ignore case), `l` (locale), `m` (multi-line), `s` (dot matches all), or `x` (verbose).
2626

27-
This is equivalent to the above example, with `(?im)` setting the multi-line and ignore case flags:
27+
This is equivalent to the above example, with `(?im)` setting the `multiline_flag` and `ignorecase_flag`:
2828

2929
```yaml
3030
- action: FirstRegExMatch
@@ -58,6 +58,70 @@ output_pipeline:
5858
last_heading_pattern: (?im)^## \d+\.\d+(?:\.\d+)?\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)$
5959
```
6060

61+
## Providing links to commits and version diffs
62+
63+
With a bit of configuration and custom templating, you can provide a link to each commit and a diff between versions on your git repository.
64+
65+
Add the link to your repository as a [configuration variable](configuration-variables):
66+
67+
```yaml
68+
variables:
69+
repo_url: https://github.com/coordt/generate-changelog
70+
```
71+
72+
Then create a `version_heading.md.jinja` file in `.github/changelog_templates/` or other [configured template directory](configuration-template_dirs). Its contents should be similar to the following:
73+
74+
```jinja
75+
## {{ version.label }} ({{ version.date_time.strftime("%Y-%m-%d") }})
76+
77+
[Compare the full difference.]({{ repo_url }}/compare/{{ version.previous_tag }}...{{ version.tag }})
78+
```
79+
80+
```{note}
81+
If you use this pattern and generate the changelog before tagging the commit, the `version.tag` will always be `HEAD`.
82+
83+
You will need to either manually change this or use an automated method such as [bump2version](https://github.com/c4urself/bump2version). [See below for more information.](#incremental-changelog-with-bump2version)
84+
```
85+
86+
For showing a specific commit link, create a `commit.md.jinja` file in `.github/changelog_templates/ or other [configured template directory](configuration-template_dirs). Its contents should include something like
87+
```jinja
88+
[{{ commit.short_sha }}]({{ repo_url }}/commit/{{ commit.sha }})
89+
```
90+
91+
For example:
92+
93+
```jinja
94+
- {{ commit.summary }} [{{ commit.short_sha }}]({{ repo_url }}/commit/{{ commit.sha }})
95+
{{ commit.body|indent(2, first=True) }}
96+
{% for key, val in commit.metadata["trailers"].items() %}
97+
{% if key not in VALID_AUTHOR_TOKENS %}
98+
**{{ key }}:** {{ val|join(", ") }}
99+
100+
{% endif %}
101+
{% endfor %}
102+
```
103+
104+
## Incremental changelog with bump2version
105+
106+
You can generate the incremental changelog just before using [bump2version](https://github.com/c4urself/bump2version) to bump the version of your project.
107+
108+
First, follow the steps for configuring generate-changelog for [incremental change logs](#incremental-change-logs).
109+
110+
Then configure bump2version to modify the CHANGELOG.md file:
111+
112+
```ini
113+
[bumpversion:file(version heading):CHANGELOG.md]
114+
search = Unreleased
115+
```
116+
117+
If you are including links to [version diffs](#providing-links-to-commits-and-version-diffs), also add:
118+
119+
```ini
120+
[bumpversion:file(diff link):CHANGELOG.md]
121+
search = {current_version}...HEAD
122+
replace = {current_version}...{new_version}
123+
```
124+
61125
## Parsing commit trailers
62126

63127
```yaml

setup.cfg

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ commit_args = --no-verify
55
tag = True
66
tag_name = {new_version}
77
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\+\w+-(?P<dev>\d+))?
8-
serialize =
8+
serialize =
99
{major}.{minor}.{patch}+{$BRANCH_NAME}-{dev}
1010
{major}.{minor}.{patch}
1111
message = Version updated from {current_version} to {new_version}
@@ -19,7 +19,7 @@ license_files = LICENSE
1919
url = https://github.com/coordt/generate_changelog
2020
author = Corey Oordt
2121
author_email = coreyoordt@gmail.com
22-
classifiers =
22+
classifiers =
2323
Environment :: Console
2424
Development Status :: 4 - Beta
2525
Intended Audience :: Developers
@@ -36,7 +36,7 @@ classifiers =
3636
long_description = file:README.md
3737
long_description_content_type = text/markdown
3838
keywords = changelog, change, git, commit
39-
project_urls =
39+
project_urls =
4040
Documentation = https://coordt.github.io/generate-changelog/
4141
Source = https://github.com/coordt/generate-changelog
4242

@@ -47,19 +47,19 @@ python_requires = >=3.7
4747
packages = find:
4848

4949
[options.packages.find]
50-
exclude =
50+
exclude =
5151
example*
5252
tests*
5353
docs*
5454
build
5555

5656
[options.entry_points]
57-
console_scripts =
57+
console_scripts =
5858
generate-changelog = generate_changelog.cli:app
5959

6060
[flake8]
6161
ignore = D203,W503
62-
exclude =
62+
exclude =
6363
.git,
6464
.tox,
6565
docs,
@@ -76,6 +76,6 @@ ignore = DAR402
7676
[bumpversion:file(version heading):CHANGELOG.md]
7777
search = Unreleased
7878

79-
[bumpversion:file(previous version):CHANGELOG.md]
79+
[bumpversion:file(diff link):CHANGELOG.md]
8080
search = {current_version}...HEAD
8181
replace = {current_version}...{new_version}

0 commit comments

Comments
 (0)