Skip to content

Commit abd0c96

Browse files
committed
Removed the lazy objects.
1 parent 75b2d35 commit abd0c96

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

generate_changelog/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ def main(
7676
repository = Repo(search_parent_directories=True)
7777

7878
# get starting tag based on configuration
79-
start_tag_pipeline = pipeline_factory(config.starting_tag_pipeline, **config.variables)
80-
starting_tag = start_tag_pipeline.run()
79+
if config.starting_tag_pipeline:
80+
start_tag_pipeline = pipeline_factory(config.starting_tag_pipeline, **config.variables)
81+
starting_tag = start_tag_pipeline.run()
82+
else:
83+
starting_tag = None
84+
8185
if not starting_tag:
8286
typer.echo("No starting tag found. Generating entire change log.")
8387
else:

generate_changelog/pipeline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ def run(self, context: dict, input_value: Any) -> str:
9797
Returns:
9898
The processed string
9999
"""
100-
from generate_changelog.templating import pipeline_env
100+
from generate_changelog.templating import get_pipeline_env
101101

102102
# render string args, and kwarg-values using jinja2
103103
new_args = [
104-
pipeline_env.from_string(arg, globals=context).render() if isinstance(arg, str) else arg
104+
get_pipeline_env().from_string(arg, globals=context).render() if isinstance(arg, str) else arg
105105
for arg in self._args
106106
]
107107

108108
new_kwargs = {
109-
key: pipeline_env.from_string(val, globals=context).render() if isinstance(val, str) else val
109+
key: get_pipeline_env().from_string(val, globals=context).render() if isinstance(val, str) else val
110110
for key, val in self._kwargs.items()
111111
}
112112

generate_changelog/utilities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def eval_if_callable(value: Any) -> Any:
2929

3030
if is_action(value):
3131
# convert it into a single action and call it
32-
return pipeline_factory([value], **config.variables).run()
32+
return pipeline_factory([value], **config.rendered_variables).run()
3333
elif is_pipeline(value):
34-
return pipeline_factory(value, **config.variables).run()
34+
return pipeline_factory(value, **config.rendered_variables).run()
3535

3636
return value() if callable(value) else value
3737

test/test_cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ def test_app_version():
1616
assert generate_changelog.__version__ in result.stdout
1717

1818

19-
def test_app_generate_config():
19+
def test_app_generate_config(mocker):
20+
func = mocker.patch("generate_changelog.cli.write_default_config")
2021
result = runner.invoke(app, ["--generate-config"])
2122
if result.exit_code != 0:
2223
print(result.stdout)
24+
traceback.print_exception(*result.exc_info)
2325
assert result.exit_code == 0
26+
func.assert_called()
2427
assert "The configuration file was written to" in result.stdout
2528

2629

2730
def test_app_generate_changelog(default_repo):
28-
config = Path(__file__).parent / "fixtures" / "sample_config.yml"
31+
config = Path(__file__).parent / "fixtures" / "std-out-config.yaml"
2932
result = runner.invoke(app, ["-r", default_repo.git_dir, "-c", str(config)])
3033
if result.exit_code != 0:
3134
print(result.stdout)

0 commit comments

Comments
 (0)