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:125–141  ·  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

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

Callers 1

run_asyncMethod · 0.85

Calls 5

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

Tested by

no test coverage detected