Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Replace opaque bool param with a CloneFormat enum

+16 -10
+16 -10
compiler-cli/src/dependencies.rs
··· 1232 1232 project_paths: &ProjectPaths, 1233 1233 ) -> Result<GitCheckout, Error> { 1234 1234 let clone_path = project_paths.build_packages_package(package_name); 1235 - prepare_git_clone(&clone_path, repo, false)?; 1235 + prepare_git_clone(&clone_path, repo, CloneFormat::WorkTree)?; 1236 1236 let _ = execute_command(git_command(&clone_path).arg("checkout").arg(ref_))?; 1237 1237 let output = execute_command(git_command(&clone_path).arg("rev-parse").arg("HEAD"))?; 1238 1238 let commit = git_stdout(output); ··· 1248 1248 subdir: &Utf8Path, 1249 1249 ) -> Result<GitCheckout, Error> { 1250 1250 let clone_path = project_paths.build_git_repo(&git_repo_dir_name(repo)); 1251 - prepare_git_clone(&clone_path, repo, true)?; 1251 + prepare_git_clone(&clone_path, repo, CloneFormat::Bare)?; 1252 1252 1253 1253 let commit = resolve_git_ref(&clone_path, repo, ref_)?; 1254 1254 ··· 1291 1291 }) 1292 1292 } 1293 1293 1294 + #[derive(Clone, Copy)] 1295 + enum CloneFormat { 1296 + /// A regular clone with a checked-out work tree. 1297 + WorkTree, 1298 + /// A bare repository with no work tree. 1299 + Bare, 1300 + } 1301 + 1294 1302 /// Initialise (or reuse) a git clone at the given path and fetch from the 1295 - /// remote repository. When `bare` is set the clone is a bare repository with 1296 - /// no work tree. 1297 - fn prepare_git_clone(clone_path: &Utf8Path, repo: &str, bare: bool) -> Result<()> { 1303 + /// remote repository. 1304 + fn prepare_git_clone(clone_path: &Utf8Path, repo: &str, format: CloneFormat) -> Result<()> { 1298 1305 // If the clone path exists but is not the kind of git repo we expect, we 1299 1306 // need to remove the directory. 1300 - let reusable = if bare { 1301 - fs::is_bare_git_repo_root(clone_path) 1302 - } else { 1303 - fs::is_git_work_tree_root(clone_path) 1307 + let reusable = match format { 1308 + CloneFormat::Bare => fs::is_bare_git_repo_root(clone_path), 1309 + CloneFormat::WorkTree => fs::is_git_work_tree_root(clone_path), 1304 1310 }; 1305 1311 1306 1312 if !reusable { ··· 1311 1317 1312 1318 let mut init = git_command(clone_path); 1313 1319 let _ = init.arg("init"); 1314 - if bare { 1320 + if matches!(format, CloneFormat::Bare) { 1315 1321 let _ = init.arg("--bare"); 1316 1322 } 1317 1323 let _ = execute_command(&mut init)?;