Comments (3)
@codejedi365 thanks for letting me know. :)
Until we get the new release with the changelog rewrite, I can suggest the following patch for whoever is using this tool in a monorepo like me (note that I have no idea if this is good, I haven't looked much into the codebase, I just needed a quick fix for now):
unchanged:
--- a/cli/commands/changelog.py
+++ b/cli/commands/changelog.py
@@ -3,6 +3,7 @@ from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING
+from pathlib import Path
import click
@@ -76,7 +77,8 @@ def changelog(ctx: click.Context, release_tag: str | None = None) -> None:
f"{template_dir!r} relative to {repo.working_dir!r}"
)
else:
- recursive_render(template_dir, environment=env, _root_dir=repo.working_dir)
+ project_root = Path(runtime.global_cli_options.config_file).absolute().parent
+ recursive_render(template_dir, environment=env, _root_dir=project_root)
if release_tag:
if runtime.global_cli_options.noop:
@@ -116,4 +118,4 @@ def changelog(ctx: click.Context, release_tag: str | None = None) -> None:
)
except Exception as e:
log.exception(e)
- ctx.fail(str(e))
\ No newline at end of file
+ ctx.fail(str(e))
unchanged:
--- a/cli/config.py
+++ b/cli/config.py
@@ -395,9 +395,10 @@ class RuntimeContext:
)
# changelog_file
+ project_root = Path(global_cli_options.config_file).absolute().parent
changelog_file = Path(raw.changelog.changelog_file).resolve()
- template_dir = Path(repo.working_tree_dir or ".") / raw.changelog.template_dir
+ template_dir = Path(project_root or ".") / raw.changelog.template_dir
template_environment = environment(
template_dir=raw.changelog.template_dir,
@@ -434,4 +435,4 @@ class RuntimeContext:
# credential masker
self.apply_log_masking(self.masker)
- return self
\ No newline at end of file
+ return self
only in patch2:
unchanged:
--- a/cli/commands/version.py
+++ b/cli/commands/version.py
@@ -5,6 +5,7 @@ import os
import subprocess
from contextlib import nullcontext
from datetime import datetime
+from pathlib import Path
from typing import TYPE_CHECKING, ContextManager, Iterable
import click
@@ -402,6 +403,7 @@ def version( # noqa: C901
hvcs_client=hvcs_client, release_history=rh
)
changelog_context.bind_to_environment(env)
+ project_root = Path(runtime.global_cli_options.config_file).absolute().parent
updated_paths: list[str] = []
if update_changelog:
@@ -409,13 +411,13 @@ def version( # noqa: C901
if opts.noop:
noop_report(
f"would have recursively rendered the template directory "
- f"{template_dir!r} relative to {repo.working_dir!r}. "
+ f"{template_dir!r} relative to {project_root!r}. "
"Paths which would be modified by this operation cannot be "
"determined in no-op mode."
)
else:
updated_paths = recursive_render(
- template_dir, environment=env, _root_dir=repo.working_dir
+ template_dir, environment=env, _root_dir=project_root
)
else:
@@ -425,13 +427,13 @@ def version( # noqa: C901
if opts.noop:
noop_report(
"would have written your changelog to "
- + str(changelog_file.relative_to(repo.working_dir))
+ + str(changelog_file.relative_to(project_root))
)
else:
changelog_text = render_default_changelog_file(env)
changelog_file.write_text(changelog_text, encoding="utf-8")
- updated_paths = [str(changelog_file.relative_to(repo.working_dir))]
+ updated_paths = [str(changelog_file.relative_to(project_root))]
if commit_changes and opts.noop:
noop_report(
which instead of using the repository root directory as reference, uses the folder where the config is located.
from python-semantic-release.
@deme3 Thanks for the bug report and the initial troubleshooting you have accomplished. I have been working an extensive rewrite of the changelog testing and this will definitely be one of the new tests to add along with a fix.
from python-semantic-release.
Related Issues (20)
- Why is in every example git config for user.email and user.name set? HOT 1
- version_variables not working HOT 2
- How to get the program to analyse all the previous commits and increase the version number in a cumulative way HOT 9
- All pre-release changelog on release. HOT 6
- GitHub Actions can't create release: `ValueError: release id for tag <tag> not found, and could not be created` HOT 4
- BREAKING CHANGE does not appear to cause major version bump HOT 4
- How to pre-release in all other branch. HOT 2
- Add emojis in release and changelog HOT 3
- Github release creation fails with "Error: Unauthorized" despite GH_TOKEN HOT 6
- v10.0.0
- CLI option to check and fix incorrect commit messages HOT 1
- AttributeError: 'TOMLDocument' object has no attribute 'unwrap' HOT 1
- Implement CLI option to base versioning on latest tag only HOT 3
- configure changelog.md.j2 to have only final releases in the generated changelog.md HOT 3
- multibranch release version incorrectly incremented HOT 4
- Help not shown if semantic-release not configured HOT 2
- GitHub action raises stderr: 'error: src refspec main matches more than one HOT 3
- multibranch releases convert semver version to pep440 version HOT 2
- Updating version_variables that follow tag_format HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-semantic-release.