Giter Site home page Giter Site logo

Comments (3)

deme3 avatar deme3 commented on May 29, 2024 2

@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.

codejedi365 avatar codejedi365 commented on May 29, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.