Skip to content

Commit 0bed08e

Browse files
committed
Fixed missing variables in render context.
1 parent 91e4592 commit 0bed08e

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

generate_changelog/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ def main(
6363
repository = Repo(search_parent_directories=True)
6464

6565
# get starting tag based on configuration
66-
start_tag_pipeline = pipeline_factory(config.starting_tag_pipeline)
66+
start_tag_pipeline = pipeline_factory(config.starting_tag_pipeline, **config.variables)
6767
starting_tag = start_tag_pipeline.run()
6868
if not starting_tag:
6969
typer.echo("No starting tag found. Generating entire change log.")
7070
else:
7171
typer.echo(f"Generating change log from tag: '{starting_tag}'.")
7272

7373
# use the output pipeline to deal with the rendered change log.
74-
output_pipeline = pipeline_factory(config.output_pipeline)
74+
output_pipeline = pipeline_factory(config.output_pipeline, **config.variables)
7575
output_pipeline.run(templating.render(repository, config, starting_tag))
7676

7777

generate_changelog/pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def pipeline_factory(
130130
action_list: list,
131131
commit_metadata_func: Optional[Callable] = None,
132132
version_metadata_func: Optional[Callable] = None,
133+
**kwargs,
133134
) -> Pipeline:
134135
"""Create a Pipeline from a list of configured actions."""
135136
action_specs = [ActionSpec(**action) for action in action_list]
@@ -144,4 +145,4 @@ def pipeline_factory(
144145
)
145146
for a in action_specs
146147
]
147-
return Pipeline(actions=actions)
148+
return Pipeline(actions=actions, **kwargs)

generate_changelog/templating.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,17 @@ def get_context_from_tags(repository: Repo, config: Configuration, starting_tag:
185185

186186
def render(repository: Repo, config: Configuration, starting_tag: Optional[str] = None) -> str:
187187
"""Render the changelog for the repository to a string."""
188-
context = get_context_from_tags(repository, config, starting_tag)
188+
version_context = get_context_from_tags(repository, config, starting_tag)
189+
context = get_config().variables.copy()
190+
context["versions"] = version_context
191+
context["VALID_AUTHOR_TOKENS"] = get_config().valid_author_tokens
192+
189193
if starting_tag:
190194
heading_str = default_env.get_template("heading.md.jinja").render()
191-
versions_str = default_env.get_template("versions.md.jinja").render(
192-
{"versions": context, "VALID_AUTHOR_TOKENS": get_config().valid_author_tokens}
193-
)
195+
versions_str = default_env.get_template("versions.md.jinja").render(context)
194196
return "\n".join([heading_str, versions_str])
195197

196-
return default_env.get_template("base.md.jinja").render(
197-
{"versions": context, "VALID_AUTHOR_TOKENS": get_config().valid_author_tokens}
198-
)
198+
return default_env.get_template("base.md.jinja").render(context)
199199

200200

201201
def first_matching(section_patterns: dict, string: str) -> str:

generate_changelog/utilities.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ def is_pipeline(value: Any) -> bool:
1414

1515
def eval_if_callable(value: Any) -> Any:
1616
"""Return value or the result of calling value."""
17+
from generate_changelog.configuration import get_config
1718
from generate_changelog.pipeline import pipeline_factory
1819

20+
config = get_config()
21+
1922
if is_action(value):
2023
# convert it into a single action and call it
21-
return pipeline_factory([value]).run()
24+
return pipeline_factory([value], **config.variables).run()
2225
elif is_pipeline(value):
23-
return pipeline_factory(value).run()
26+
return pipeline_factory(value, **config.variables).run()
2427

2528
return value() if callable(value) else value
2629

0 commit comments

Comments
 (0)