Skip to content

Shared metadata and Git input

Shared metadata and Git input

FlowDelta and FlexiPageDelta keep their own policies and pipelines, but they share one small boundary: reading metadata from disk or Git. That boundary runs Git, reads a metadata file at a ref, and discovers paths. It knows nothing about how a Flow or FlexiPage is parsed, diffed, rendered, or reported.

Modules

ModuleResponsibility
src/io/read-metadata.tsReads an XML file synchronously, or a metadata path with git show <ref>:<path>.
src/io/git.tsThe default synchronous Git adapter, the injectable GitRunner port, and classification of “missing at ref” errors.
src/io/discover-git-metadata.tsFinds metadata paths from both refs or from the changed-path diff, normalizes pattern separators, applies the matcher, and returns sorted, unique paths.

Reading

readMetadataFromFile(path) requires an .xml path. It reports a missing local file as an error and returns the contents as UTF-8 text.

readMetadataFromGit(repo, ref, filePath) returns the XML from git -C <repo> show <ref>:<filePath>. If the path doesn’t exist at that ref, it returns null. Any other Git failure is rethrown. Each product pipeline uses null to build its own empty model for added or deleted metadata.

Both Git-facing functions accept the small GitRunner port in tests. The default adapter calls execFileSync("git", ...) with a 64 MiB output limit and reports overflow explicitly.

Discovery

discoverGitMetadataFiles({ repo, fromRef, toRef, pattern, changedOnly }) follows these rules:

  • Full-tree mode lists files at both refs and unions them, so additions and deletions stay visible.
  • changedOnly mode runs git diff --no-relative --no-renames --name-only -z <from> <to> -- and applies the same matcher. Renames produce paths for both sides.
  • Git paths are repository-root-relative and NUL-delimited, including when the supplied repository directory is nested. Results are distinct and sorted.
  • A comparison warns if the pattern matches neither tree. A snapshot with no matches fails in the Flow CLI.
  • Patterns support literal paths, * within one path segment, ** across segments, and ? for one non-separator character. Brackets and other glob syntax are treated literally. There’s no glob dependency.

Each CLI keeps its own argument policy. Flow Git mode still requires --path. FlexiPage Git mode defaults to force-app/**/*.flexipage-meta.xml when --path is omitted. Each CLI also keeps its own parser, empty-model factory, artifact naming, summaries, and per-file error and exit-code handling.

Tests and limits

test/metadata-io.test.ts is the shared contract suite. It covers matching, union and changed-only discovery, Unicode renames from a subdirectory, files larger than 1 MiB, and missing-versus-unrelated Git errors. Product-level Git tests stay in test/semantic-diff.test.ts and test/flexipage-delta.test.ts, including each CLI’s path policy.

When you change this boundary, keep the two product pipelines separate. Don’t expand the glob syntax, change Salesforce org retrieval, or add a runtime dependency.