MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / new

Method new

atomic-cli/src/commands/diff/json.rs:34–47  ·  view source on GitHub ↗

Build the document. `change` is `Some` for `atomic diff -c ` and `None` for a working-copy diff; `view` is populated only for the latter.

(
        file_diffs: &[FileDiff],
        stats: &DiffStats,
        change: Option<(&Change, &Hash)>,
        view: Option<&str>,
    )

Source from the content-addressed store, hash-verified

32 /// `change` is `Some` for `atomic diff -c <hash>` and `None` for a
33 /// working-copy diff; `view` is populated only for the latter.
34 pub(super) fn new(
35 file_diffs: &[FileDiff],
36 stats: &DiffStats,
37 change: Option<(&Change, &Hash)>,
38 view: Option<&str>,
39 ) -> Self {
40 Self {
41 schema_version: DIFF_JSON_SCHEMA_VERSION,
42 view: view.map(str::to_string),
43 change: change.map(|(c, h)| JsonDiffChange::new(c, h)),
44 files: file_diffs.iter().map(JsonDiffFile::from).collect(),
45 stats: JsonDiffStats::from(stats),
46 }
47 }
48
49 /// The all-zero document, used when there is nothing to diff so that
50 /// `--json` still emits valid parseable JSON.

Callers

nothing calls this directly

Calls 6

collectMethod · 0.45
iterMethod · 0.45
to_base32Method · 0.45
lenMethod · 0.45
cloneMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected