MCPcopy Create free account
hub / github.com/brocode/fw / import

Function import

src/setup/mod.rs:136–149  ·  view source on GitHub ↗
(maybe_config: Result<Config, AppError>, path: &str)

Source from the content-addressed store, hash-verified

134}
135
136pub fn import(maybe_config: Result<Config, AppError>, path: &str) -> Result<(), AppError> {
137 let path = fs::canonicalize(Path::new(path))?;
138 let project_path = path.to_str().ok_or(AppError::InternalError("project path is not valid unicode"))?.to_owned();
139 let file_name = AppError::require(path.file_name(), AppError::UserError("Import path needs to be valid".to_string()))?;
140 let project_name: String = file_name.to_string_lossy().into_owned();
141 let maybe_settings = maybe_config.ok().map(|c| c.settings);
142 let new_project = load_project(maybe_settings, path.clone(), &project_name)?;
143 let new_project_with_path = Project {
144 override_path: Some(project_path),
145 ..new_project
146 };
147 config::write_project(&new_project_with_path)?;
148 Ok(())
149}
150
151fn load_project(maybe_settings: Option<Settings>, path_to_repo: PathBuf, name: &str) -> Result<Project, AppError> {
152 let repo: Repository = Repository::open(path_to_repo)?;

Callers 1

_mainFunction · 0.85

Calls 2

load_projectFunction · 0.85
write_projectFunction · 0.85

Tested by

no test coverage detected