(content: &[u8])
| 415 | } |
| 416 | |
| 417 | pub(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 | |
| 445 | fn migrate_legacy_import_hooks(hooks_dir: &Path, binary: &Path) -> CliResult<()> { |
| 446 | for hook_name in ["post-commit", "post-merge", "post-rewrite"] { |
no test coverage detected