Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/semantic_release/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def verify_git_repo_dir(cls, dir_path: Path) -> Path:
except InvalidGitRepositoryError as err:
raise InvalidGitRepositoryError("No valid git repository found!") from err

if dir_path.absolute() != found_path:
if dir_path.resolve() != found_path.resolve():
logging.warning(
"Found .git/ in higher parent directory rather than provided in configuration."
)
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/semantic_release/cli/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,39 @@ def test_git_remote_url_w_insteadof_alias(

# Evaluate: the remote URL should be the full URL
assert expected_url.url == actual_url


@pytest.mark.usefixtures("caplog")
def test_verify_git_repo_dir_resolves_paths(
build_configured_base_repo: BuildRepoFn,
example_project_dir: ExProjectDir,
example_pyproject_toml: Path,
update_pyproject_toml: UpdatePyprojectTomlFn,
change_to_ex_proj_dir: None,
caplog,
):
"""
Test that verify_git_repo_dir does not warn when repo_dir='.' in monorepo setup.

When repo_dir is set to '.' from a subpackage directory, the resolved paths
should match and no warning should be emitted.
"""
import logging

build_configured_base_repo(example_project_dir)

# Set repo_dir to "." (simulating running from a subpackage in a monorepo)
update_pyproject_toml("tool.semantic_release.repo_dir", ".")

# Ensure no warning is emitted when paths resolve to the same directory
with caplog.at_level(logging.WARNING):
runtime_ctx = RuntimeContext.from_raw_config(
RawConfig.model_validate(load_raw_config_file(example_pyproject_toml)),
global_cli_options=GlobalCommandLineOptions(),
)

# The warning should not be present since '.' resolves to the same dir as found_path
assert "Found .git/ in higher parent directory" not in caplog.text
# Verify the runtime context was created successfully with a resolved path
assert runtime_ctx.repo_dir is not None
assert runtime_ctx.repo_dir.is_absolute()