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

Function record

atomic-cli/src/commands/rpc.rs:625–791  ·  view source on GitHub ↗

`atomic record` over Record — every form. The message composes client-side with the SAME editor/prompt flow the local body uses (`get_message` — editors are interactive, client-side by design), `--author` parses into the wire author exactly like the local body, `--identity` names an identity the handler resolves host-side, and `--dry-run` is the Status read's preview — the same "Would record" line

(args: &super::record::Record)

Source from the content-addressed store, hash-verified

623/// `--dry-run` is the Status read's preview — the same "Would record"
624/// lines the local body prints, rendered from the wire's file entries.
625pub fn record(args: &super::record::Record) -> CliResult<bool> {
626 // These #207 operations have no RecordRequest representation yet. Keep
627 // their existing native boundary rather than silently discard the flags.
628 if args.allow_conflict_markers || !args.resolve_name_conflicts.is_empty() {
629 return Ok(false);
630 }
631 let Some(session) = Service::open()? else {
632 return Ok(false);
633 };
634 if args.dry_run {
635 let response = session.status(pb::StatusRequest {
636 repository: Some(session.reference.clone()),
637 options: None,
638 })?;
639 let entries = response
640 .files
641 .iter()
642 .map(|file| {
643 let status = match pb::FileStatus::try_from(file.status) {
644 Ok(pb::FileStatus::Modified) => atomic_repository::status::FileStatus::Modified,
645 Ok(pb::FileStatus::Deleted) => atomic_repository::status::FileStatus::Deleted,
646 Ok(pb::FileStatus::Untracked) => {
647 atomic_repository::status::FileStatus::Untracked
648 }
649 Ok(pb::FileStatus::Added) => atomic_repository::status::FileStatus::Added,
650 Ok(pb::FileStatus::Conflicted) => {
651 atomic_repository::status::FileStatus::Conflicted
652 }
653 Ok(pb::FileStatus::PendingUntrack) => {
654 atomic_repository::status::FileStatus::PendingUntrack
655 }
656 _ => atomic_repository::status::FileStatus::Clean,
657 };
658 (status, file.path.clone())
659 })
660 .collect::<Vec<_>>();
661 crate::commands::record::render_dry_run(&entries, args.all, &args.files);
662 return Ok(true);
663 }
664 // The message composes BEFORE any staging so a cancelled editor leaves
665 // the working copy untouched (the same ordering the local body uses).
666 let message = args.get_message()?;
667 // Authorship mirrors the local precedence: --identity wins over
668 // --author; the handler turns the named identity into an author and
669 // signing credentials host-side.
670 let (author, identity_name) = if let Some(name) = args.identity.clone() {
671 (None, Some(name))
672 } else {
673 // The local parse: "Name <email>" or a bare name.
674 let author = args.parse_author().map(|parsed| pb::Author {
675 name: parsed.name,
676 email: parsed.email,
677 });
678 (author, None)
679 };
680 let root = crate::commands::find_repository_root()?;
681 if args.skip_binary || args.max_size.is_some() {
682 session.ensure_record_file_options()?;

Callers 1

runMethod · 0.50

Calls 15

openFunction · 0.85
render_dry_runFunction · 0.85
find_repository_rootFunction · 0.85
relativizeFunction · 0.85
print_warningFunction · 0.85
print_hintFunction · 0.85
as_refMethod · 0.80
request_metaFunction · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected