mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-26 19:05:13 +00:00
feat(services): load service plugins from git repos
Allow directories.services entries to be git repo specs (URL/owner-repo/ @branch) alongside local paths: clone + TTL-pull as cache, list-order priority with a duplicate-ignored summary, a refresh-services command that force-syncs and reports the per-service diff, and a dirty-clone guard that protects local edits on the automated path. Adds binaries.Git and a redact_paths config toggle.
This commit is contained in:
@@ -77,13 +77,23 @@ def _path_bases() -> list[tuple[str, str]]:
|
||||
_PATH_BASES = _path_bases()
|
||||
|
||||
|
||||
def _path_redaction_enabled() -> bool:
|
||||
"""Path-prefix redaction is on unless ``config.redact_paths`` is explicitly False."""
|
||||
try:
|
||||
from unshackle.core.config import config # lazy: config doesn't import redact, so no cycle
|
||||
|
||||
return bool(getattr(config, "redact_paths", True))
|
||||
except (ImportError, AttributeError):
|
||||
return True
|
||||
|
||||
|
||||
def redact_path(text: Optional[str]) -> Optional[str]:
|
||||
"""Replace local base-directory prefixes (install root, venv, home) in ``text`` with tokens.
|
||||
|
||||
Idempotent and cheap; only touches strings that actually contain a known base dir, so URLs
|
||||
and relative paths pass through unchanged.
|
||||
and relative paths pass through unchanged. Disabled by ``config.redact_paths: false``.
|
||||
"""
|
||||
if not isinstance(text, str) or not text:
|
||||
if not isinstance(text, str) or not text or not _path_redaction_enabled():
|
||||
return text
|
||||
for base, token in _PATH_BASES:
|
||||
if base in text:
|
||||
|
||||
Reference in New Issue
Block a user