rlsbl v0.113.0 /rlsbl.checks._common
On this page

Shared helpers for rlsbl check modules: version and tag resolution, changelog context, sibling directory exclusion, and reporter text hygiene.

#rlsbl.checks._common

#rlsbl.checks._common

Shared helpers for rlsbl check modules: version and tag resolution, changelog context, sibling directory exclusion, and reporter text hygiene.

#reportable_lines

python
def reportable_lines(text, *, limit=None)

Return the non-blank lines of text, right-stripped, optionally capped.

Tool output is not safe to feed to a reporter line by line: linters like ruff separate findings with blank lines, and an empty problem text is a hard error that aborts the entire check run with no attribution to the check that produced it. Blank lines carry no finding, so they are dropped before the reporter ever sees them. limit caps the number of lines returned (applied after filtering, so a cap of 20 yields 20 real findings).

#summary_line

python
def summary_line(text, *, limit=200, fallback=_NO_TEXT)

Return the first non-blank line of text, truncated to limit chars.

Used for the one-line outcome message that accompanies a set of problems. Never returns an empty string: text that is empty or entirely blank yields fallback, because the reporter rejects an empty outcome message.

#exception_text

python
def exception_text(exc, *, fallback=None)

Return a non-empty description of exc suitable for a reporter call.

An exception raised with no message (or a whitespace-only one) stringifies to "", which the reporter rejects. Falling back to the exception's class name keeps the failure attributable to the check that hit it instead of aborting the run with an internal error.

#_resolve_version_and_tag

python
def _resolve_version_and_tag(ctx)

Detect version and tag from project targets rooted at ctx.

In explicit releasable mode, uses the releasable's version file and tag_format instead of the per-target version and tag format.

Returns (version, tag); either may be None.

#_get_changelog_context

python
def _get_changelog_context(ctx)

Resolve changes_dir, tag_glob, project, and entries for changelog checks.

Returns (changes_dir, tag_glob, project, entries) or None when the changes directory does not exist (caller should return skip).

The project value depends on mode:

  • Standalone (no workspace): None.
  • Implicit monorepo (no [[releasables]]): a single WorkspaceProject

dict with path and watch keys for scoping.

  • Explicit monorepo ([[releasables]] present): a list of

WorkspaceProject instances representing all member projects of the releasable. Callers that pass project to validation functions handle both single-project and list-of-projects via filter_commits_for_releasable.

In explicit mode, changes_dir points to the releasable's changes directory (.rlsbl-monorepo/releasables/{name}/changes/) and tag_glob is derived from the releasable's tag_format.

#_resolve_tag_glob

python
def _resolve_tag_glob(ctx)

Return the git tag glob that scopes ctx's project to its own releases.

The single derivation used by the changelog checks (:func:_get_changelog_context): the releasable's tag_format in explicit monorepo mode, the target's monorepo_tag_glob in implicit mode, and the plain v* for a standalone repo. Reused by the external-check release-context env so a consumer check resolves the same last tag rlsbl itself would.

#_get_all_changelog_contexts

python
def _get_all_changelog_contexts(ctx)

Return changelog contexts for ALL releasables when CWD is the workspace root.

When CWD is inside a specific project, delegates to _get_changelog_context and wraps the result in a list. When CWD is the workspace root in an explicit-mode workspace, iterates all releasables and returns a context tuple for each one that has a changes directory.

Returns a list of (changes_dir, tag_glob, project, entries) tuples, or an empty list when no contexts are available (caller should skip).

#_sibling_exclude_dirs

python
def _sibling_exclude_dirs(root, project_path, all_projects)

Compute sibling project directories to exclude from a scan.

For a project at project_path, returns a list of other workspace project directories that are subdirectories of this project's path. This prevents walk_source_files from descending into sibling projects when the current project is at a parent path (e.g. path = ".").

#_build_dep_import_cache

python
def _build_dep_import_cache(ctx)

Build per-project import scan cache for dependency checks.

Returns a dict mapping project name to (lib_imports, test_imports, guarded_imports). All dep checks (unused, undeclared, runtime-test-only, dev-in-lib) share one scan pass via this cache. The result is memoized on the context object so that multiple checks in the same run reuse a single scan instead of re-walking every project's source tree.

Search