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

Method record

atomic-repository/src/repository/record.rs:45–1090  ·  view source on GitHub ↗

This is the main entry point for creating a change from working copy modifications. It detects changes, creates hunks, globalizes positions, and assembles a complete change. # Arguments `header` - The change header (message, author, etc.) `options` - Options controlling recording behavior # Returns A `RecordOutcome` containing the recorded change, hash, and statistics. # Errors Returns an er

(
        &self,
        header: ChangeHeader,
        options: RecordOptions,
    )

Source from the content-addressed store, hash-verified

43 /// println!("Created change: {}", result.hash().to_base32());
44 /// ```
45 pub fn record(
46 &self,
47 header: ChangeHeader,
48 options: RecordOptions,
49 ) -> Result<RecordOutcome, RecordError> {
50 let trace_record = std::env::var_os("ATOMIC_TRACE_RECORD").is_some();
51 use atomic_core::output::Memory;
52 use atomic_core::record::workflow::{
53 assemble_change, record_added_file, record_deleted_file, record_modified_file,
54 DetectedFile, RecordedFile,
55 };
56
57 // Build the final header (may get message from options)
58 let final_header = build_header(header, &options);
59
60 // Get repository status to find modified files
61 let status_t0 = std::time::Instant::now();
62 let mut status_options = StatusOptions::default();
63 if !options.all() {
64 for path in options.get_paths() {
65 status_options = status_options.filter_path(std::path::PathBuf::from(path));
66 }
67 }
68 let status = self
69 .status_for_record(status_options, options.get_detect_raw_renames())
70 .map_err(RecordError::Repository)?;
71 if trace_record {
72 eprintln!(
73 "[record] status: {:.1}ms ({} entries)",
74 status_t0.elapsed().as_secs_f64() * 1000.0,
75 status.entries().len(),
76 );
77 }
78
79 log::debug!(
80 "record: status returned {} entries (modified={}, added={}, deleted={}, clean={}, untracked={})",
81 status.entries().len(),
82 status.modified_count(),
83 status.added_count(),
84 status.deleted_count(),
85 status.entries().iter().filter(|e| e.status() == FileStatus::Clean).count(),
86 status.untracked_count(),
87 );
88
89 // Refuse to record files that still contain conflict markers, so an
90 // unresolved merge is never baked into history. This runs over the
91 // raw status (before the recordable filter) so it also catches files
92 // reported as Conflicted. Overridable via
93 // `RecordOptions::allow_conflict_markers`.
94 if !options.get_allow_conflict_markers() {
95 for entry in status.entries() {
96 let is_directory = entry.details().map(|d| d == "directory").unwrap_or(false);
97 if is_directory {
98 continue;
99 }
100 if !matches!(
101 entry.status(),
102 FileStatus::Added | FileStatus::Modified | FileStatus::Conflicted

Callers 15

runMethod · 0.45
execute_reviseMethod · 0.45
runMethod · 0.45
runMethod · 0.45
record_allFunction · 0.45
remediation_reportFunction · 0.45
report_with_intentFunction · 0.45
review_gate_reportFunction · 0.45

Calls 15

build_headerFunction · 0.85
filter_filesFunction · 0.85
addedFunction · 0.85
record_added_fileFunction · 0.85
deletedFunction · 0.85
record_deleted_fileFunction · 0.85
get_inode_positionFunction · 0.85
decode_trunk_idFunction · 0.85