Skip to content

Commit 6e3c78b

Browse files
Merge pull request #34 from JonasScharpf/feature/make-base-url-of-links-configurable
Make URL to tags in rendered changelog configurable
2 parents 442fd5e + 43642c2 commit 6e3c78b

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

.snippets/33.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Make URL to tags in rendered changelog configurable
2+
<!--
3+
type: feature
4+
scope: all
5+
affected: all
6+
-->
7+
8+
Introduce `--version-reference` to make the URL to the tags in the rendered changelog configurable

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ the changelog generation. This is useful if those changes are not affecting
124124
the "product" like internal documentation changes or similar things, which e.g.
125125
do not require a deployment.
126126

127+
The option `--version-reference` allows to configure the URL to the tags in the
128+
rendered changelog file. Use e.g.
129+
`https://github.com/<GITHUB_USER>/<PROJECT_USING_SNIPPETS2CHANGELOG>/tree/`
130+
for a project using this package.
131+
127132
### Parse
128133

129134
Parse an existing snippet file and return the data as JSON without indentation

snippets2changelog/cli.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def parse_args(argv: Union[Sequence[str], None] = None) -> Args:
8080
action='store_true',
8181
help="Print latest changelog entry as JSON instead of updating the changelog file",
8282
)
83+
parser_changelog.add_argument(
84+
"--version-reference",
85+
type=str,
86+
help="Base version reference for links to tags in rendered changelog",
87+
default="https://github.com/brainelectronics/snippets2changelog/tree/",
88+
)
8389

8490
parser_create = subparsers.add_parser(
8591
"create",
@@ -130,7 +136,7 @@ def fn_info(_args: Args) -> None:
130136

131137
def fn_changelog(args: Args) -> None:
132138
cc = ChangelogCreator(changelog=args.changelog, snippets_folder=args.snippets, update_in_place=args.in_place, skip_internal=args.no_internal, verbosity=args.verbose)
133-
cc.update_changelog(dry_run=args.dry_run)
139+
cc.update_changelog(dry_run=args.dry_run, version_reference=args.version_reference)
134140

135141

136142
def fn_create(args: Args) -> None:

snippets2changelog/creator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(self, changelog: Path, snippets_folder: Path, update_in_place: boo
9090

9191
self._skip_internal = skip_internal
9292

93-
def update_changelog(self, dry_run: bool = False) -> None:
93+
def update_changelog(self, dry_run: bool = False, version_reference: str = "https://github.com/brainelectronics/snippets2changelog/tree/") -> None:
9494
new_changelog_content = ""
9595
# create a "prolog" and an "epilog", with the new content in between
9696
existing_changelog_content = read_file(path=self._changelog, parse="read").split(self._version_line)
@@ -124,7 +124,7 @@ def update_changelog(self, dry_run: bool = False) -> None:
124124
"affected": snippet_content["affected"],
125125
},
126126
"content": snippet_content["details"],
127-
"version_reference": f"https://github.com/brainelectronics/snippets2changelog/tree/{self.semver_data}",
127+
"version_reference": f"{version_reference}/{self.semver_data}",
128128
}
129129
latest_changelog_entry = changelog_entry_content
130130
self._logger.debug(f"changelog_entry_content: {changelog_entry_content}")

0 commit comments

Comments
 (0)