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

Method run_import

atomic-cli/src/commands/git/import.rs:1108–1866  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

1106 }
1107
1108 fn run_import(&self) -> CliResult<()> {
1109 let run_start = std::time::Instant::now();
1110 if self.stream || self.uses_span() || self.stream_window_mib.is_some() {
1111 self.stream_limits()?;
1112 }
1113 if self.no_stream && self.stream {
1114 return Err(CliError::GitError {
1115 message: "--stream and --no-stream cannot be combined".into(),
1116 });
1117 }
1118 // Open Git repository
1119 let git_repo = GitRepository::discover(".").map_err(|_| CliError::GitError {
1120 message: "Not a git repository (or any parent up to mount point)".to_string(),
1121 })?;
1122
1123 let workdir = git_repo.workdir().ok_or_else(|| CliError::GitError {
1124 message: "Git repository has no working directory (bare repository?)".to_string(),
1125 })?;
1126 #[cfg(feature = "experimental-span-import")]
1127 if self.span && self.incremental {
1128 return self.run_span_incremental(&git_repo, workdir);
1129 }
1130 // Keep capability inspection and the later workspace entry under one
1131 // common lock. Never run writable recovery before this check: the
1132 // ordinary importer cannot publish into a span-backed repository.
1133 let _import_preflight = Repository::try_lock_git_import_without_span(workdir, self.dry_run)
1134 .map_err(|error| CliError::GitError {
1135 message: format!("Git import preflight refused: {error}"),
1136 })?;
1137 if self.uses_span() && workdir.join(".atomic").exists() {
1138 return Err(CliError::GitError {
1139 message: "--span requires a fresh Git checkout without an Atomic repository".into(),
1140 });
1141 }
1142 trace_git_import(format!(
1143 "discover Git repository: {:?}",
1144 run_start.elapsed()
1145 ));
1146
1147 // Dry run mode
1148 if self.dry_run {
1149 print_info("Dry run mode - no changes will be made");
1150
1151 let default_branch = self.get_default_branch(&git_repo)?;
1152 let branches = if self.all_branches {
1153 self.get_all_branches(&git_repo)?
1154 } else {
1155 vec![self.branch.clone().unwrap_or(default_branch)]
1156 };
1157
1158 // For an incremental forecast, open the existing Atomic repo
1159 // read-only so we can subtract what each branch's view already
1160 // contains. A fresh (not-yet-initialized) repo has nothing
1161 // imported, so the forecast is the full history — which is correct.
1162 // The dry run selects the explicit Observe mode: it never mutates.
1163 // Ordinary read-only opens now migrate the legacy database layout.
1164 // Require that migration separately rather than move files in a preview.
1165 if self.incremental

Callers 1

runMethod · 0.80

Calls 15

trace_git_importFunction · 0.85
print_infoFunction · 0.85
has_databaseFunction · 0.85
observe_workspaceFunction · 0.85
print_warningFunction · 0.85
has_binding_transportFunction · 0.85
current_git_branchFunction · 0.85

Tested by

no test coverage detected