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

Function parse_push_trailer

atomic-cli/src/commands/git/parallel.rs:8851–8884  ·  view source on GitHub ↗

Parse `atomic git push` trailers from a commit message. Only matches when the trailers form the message's final paragraph — the shape `atomic git push` itself produces. Trailer lines embedded mid-body (e.g. a GitHub squash-merge message quoting the original commit) do NOT match: those commits may carry conflict resolutions and must be imported.

(message: &str)

Source from the content-addressed store, hash-verified

8849/// (e.g. a GitHub squash-merge message quoting the original commit) do NOT
8850/// match: those commits may carry conflict resolutions and must be imported.
8851fn parse_push_trailer(message: &str) -> Option<PushTrailer> {
8852 let last_paragraph = message.trim_end().rsplit("\n\n").next()?;
8853
8854 let mut view = None;
8855 let mut state = None;
8856 let mut changes = Vec::new();
8857 for line in last_paragraph.lines() {
8858 let line = line.trim();
8859 if let Some(value) = line.strip_prefix("Atomic-View:") {
8860 view = Some(value.trim().to_string());
8861 } else if let Some(value) = line.strip_prefix("Atomic-State:") {
8862 state = Merkle::from_base32(value.trim().as_bytes());
8863 } else if let Some(value) = line.strip_prefix("Atomic-Changes:") {
8864 changes.extend(split_atomic_changes_value(value));
8865 } else if line.starts_with("Atomic-Manifest:")
8866 || line.starts_with("Atomic-Policy:")
8867 || line.starts_with("Atomic-Algorithm:")
8868 || line.starts_with("Atomic-Tree:")
8869 {
8870 // These publication claims are verified by the prospective/state
8871 // project-tree comparisons rather than trusted as identities.
8872 } else {
8873 // Non-trailer content in the final paragraph — not a commit
8874 // produced by `atomic git push`.
8875 return None;
8876 }
8877 }
8878
8879 Some(PushTrailer {
8880 view: view?,
8881 state: state?,
8882 changes,
8883 })
8884}
8885
8886/// Extract metadata from a git commit.
8887///

Calls 5

extendMethod · 0.80
nextMethod · 0.45
linesMethod · 0.45
as_bytesMethod · 0.45