MCPcopy Index your code
hub / github.com/github/spec-kit / write_file_and_record

Method write_file_and_record

src/specify_cli/integrations/base.py:457–475  ·  view source on GitHub ↗

Write *content* to *dest*, hash it, and record in *manifest*. Creates parent directories as needed. Writes bytes directly to avoid platform newline translation (CRLF on Windows). Any ``\r\n`` sequences in *content* are normalised to ``\n`` before writing. Returns

(
        content: str,
        dest: Path,
        project_root: Path,
        manifest: IntegrationManifest,
    )

Source from the content-addressed store, hash-verified

455
456 @staticmethod
457 def write_file_and_record(
458 content: str,
459 dest: Path,
460 project_root: Path,
461 manifest: IntegrationManifest,
462 ) -> Path:
463 """Write *content* to *dest*, hash it, and record in *manifest*.
464
465 Creates parent directories as needed. Writes bytes directly to
466 avoid platform newline translation (CRLF on Windows). Any
467 ``\r\n`` sequences in *content* are normalised to ``\n`` before
468 writing. Returns *dest*.
469 """
470 dest.parent.mkdir(parents=True, exist_ok=True)
471 normalized = content.replace("\r\n", "\n")
472 dest.write_bytes(normalized.encode("utf-8"))
473 rel = dest.resolve().relative_to(project_root.resolve())
474 manifest.record_existing(rel)
475 return dest
476
477 def integration_scripts_dir(self) -> Path | None:
478 """Return path to this integration's bundled ``scripts/`` directory.

Callers 10

setupMethod · 0.80
setupMethod · 0.80
setupMethod · 0.80
setupMethod · 0.80
_setup_defaultMethod · 0.80
setupMethod · 0.80
setupMethod · 0.80

Calls 2

record_existingMethod · 0.80
resolveMethod · 0.45

Tested by 1