Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make URL to tags in rendered changelog configurable #34

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .snippets/33.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Make URL to tags in rendered changelog configurable
<!--
type: feature
scope: all
affected: all
-->

Introduce `--version-reference` to make the URL to the tags in the rendered changelog configurable
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ the changelog generation. This is useful if those changes are not affecting
the "product" like internal documentation changes or similar things, which e.g.
do not require a deployment.

The option `--version-reference` allows to configure the URL to the tags in the
rendered changelog file. Use e.g.
`https://github.com/<GITHUB_USER>/<PROJECT_USING_SNIPPETS2CHANGELOG>/tree/`
for a project using this package.

### Parse

Parse an existing snippet file and return the data as JSON without indentation
Expand Down
8 changes: 7 additions & 1 deletion snippets2changelog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def parse_args(argv: Union[Sequence[str], None] = None) -> Args:
action='store_true',
help="Print latest changelog entry as JSON instead of updating the changelog file",
)
parser_changelog.add_argument(
"--version-reference",
type=str,
help="Base version reference for links to tags in rendered changelog",
default="https://github.com/brainelectronics/snippets2changelog/tree/",
)

parser_create = subparsers.add_parser(
"create",
Expand Down Expand Up @@ -130,7 +136,7 @@ def fn_info(_args: Args) -> None:

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


def fn_create(args: Args) -> None:
Expand Down
4 changes: 2 additions & 2 deletions snippets2changelog/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, changelog: Path, snippets_folder: Path, update_in_place: boo

self._skip_internal = skip_internal

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