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

Function normalize_base32

atomic-cli/tests/it/git_shim_cb13d_test.rs:106–130  ·  view source on GitHub ↗

Replace runs of base32 characters (Atomic state identities) with a placeholder so cross-repository comparisons compare shapes, not per-repository change hashes.

(text: &str)

Source from the content-addressed store, hash-verified

104/// placeholder so cross-repository comparisons compare shapes, not
105/// per-repository change hashes.
106fn normalize_base32(text: &str) -> String {
107 let mut normalized = String::with_capacity(text.len());
108 let mut run = String::new();
109 for character in text.chars() {
110 // Standard base32 (RFC 4648): uppercase letters plus digits 2-7.
111 let matches = character.is_ascii_uppercase() || ('2'..='7').contains(&character);
112 if matches {
113 run.push(character);
114 } else {
115 if run.len() >= 32 {
116 normalized.push_str("<state>");
117 } else {
118 normalized.push_str(&run);
119 }
120 run.clear();
121 normalized.push(character);
122 }
123 }
124 if run.len() >= 32 {
125 normalized.push_str("<state>");
126 } else {
127 normalized.push_str(&run);
128 }
129 normalized
130}
131
132fn git_ok(root: &Path, args: &[&str]) -> String {
133 let output = git(root, args);

Callers 1

equivalence_identityMethod · 0.70

Calls 4

clearMethod · 0.65
lenMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected