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

Function has_local_only_changes

atomic-cli/src/commands/pull/helpers.rs:123–139  ·  view source on GitHub ↗

Check if there are local-only changes (changes not on the remote). Returns true if the local repository has changes that are not present on the remote. This indicates a potential divergence in history. # Arguments `local_entries` - Local history entries `remote_entries` - Remote changelist entries # Returns `true` if there are local changes not present on the remote. # Example ```rust,ignor

(
    local_entries: &[HistoryEntry],
    remote_entries: &[ChangelistEntry],
)

Source from the content-addressed store, hash-verified

121/// }
122/// ```
123pub fn has_local_only_changes(
124 local_entries: &[HistoryEntry],
125 remote_entries: &[ChangelistEntry],
126) -> bool {
127 // Empty local means no local-only changes
128 if local_entries.is_empty() {
129 return false;
130 }
131
132 // Build set of remote hashes
133 let remote_hashes: HashSet<String> = remote_entries.iter().map(|e| e.hash.clone()).collect();
134
135 // Check if any local change is not on remote
136 local_entries
137 .iter()
138 .any(|e| !remote_hashes.contains(&e.hash.to_base32()))
139}
140
141/// Find all local-only change hashes.
142///

Callers 1

run_asyncMethod · 0.85

Calls 6

is_emptyMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45
containsMethod · 0.45
to_base32Method · 0.45

Tested by

no test coverage detected