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

Function is_legacy_atomic_only

atomic-cli/src/commands/git/hooks.rs:417–443  ·  view source on GitHub ↗
(content: &[u8])

Source from the content-addressed store, hash-verified

415}
416
417pub(super) fn is_legacy_atomic_only(content: &[u8]) -> bool {
418 let Ok(content) = std::str::from_utf8(content) else {
419 return false;
420 };
421 let mut in_atomic_section = false;
422 let mut saw_begin = false;
423 let mut saw_end = false;
424
425 for line in content.lines() {
426 let trimmed = line.trim();
427 if trimmed == LEGACY_MARKER_BEGIN && !in_atomic_section && !saw_begin {
428 in_atomic_section = true;
429 saw_begin = true;
430 continue;
431 }
432 if trimmed == LEGACY_MARKER_END && in_atomic_section {
433 in_atomic_section = false;
434 saw_end = true;
435 continue;
436 }
437 if !in_atomic_section && !trimmed.is_empty() && trimmed != "#!/bin/sh" {
438 return false;
439 }
440 }
441
442 saw_begin && saw_end && !in_atomic_section
443}
444
445fn migrate_legacy_import_hooks(hooks_dir: &Path, binary: &Path) -> CliResult<()> {
446 for hook_name in ["post-commit", "post-merge", "post-rewrite"] {

Callers 3

remove_owned_hookFunction · 0.85

Calls 2

linesMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected