diff --git a/recipes/dev/rust/recipe.toml b/recipes/dev/rust/recipe.toml index add723fef..933fbdbda 100644 --- a/recipes/dev/rust/recipe.toml +++ b/recipes/dev/rust/recipe.toml @@ -1,8 +1,6 @@ [source] git = "https://gitlab.redox-os.org/redox-os/rust.git" branch = "redox-2025-10-03" -# due to heavy git operation, this will only clone once and will not refetch -# if you want to refetch or changing the branch, please run `make ucr.rust` shallow_clone = true [build] diff --git a/src/cook/fetch.rs b/src/cook/fetch.rs index b04deec59..7b4f15a2a 100644 --- a/src/cook/fetch.rs +++ b/src/cook/fetch.rs @@ -146,7 +146,10 @@ pub fn fetch(recipe_dir: &Path, recipe: &Recipe, logger: &PtyOut) -> Result { //TODO: use libgit? - let shallow_clone = *shallow_clone == Some(true); + let shallow_clone = match shallow_clone { + Some(o) => *o, + None => rev.is_some(), + }; if !source_dir.is_dir() { // Create source.tmp let source_dir_tmp = recipe_dir.join("source.tmp"); @@ -162,15 +165,16 @@ pub fn fetch(recipe_dir: &Path, recipe: &Recipe, logger: &PtyOut) -> Result Result 0 { + let mut command = Command::new("git"); + command.arg("-C").arg(&source_dir); + command.arg("reset").arg("--hard"); + run_command(command, logger)?; + } //TODO: complicated stuff to check and reset branch to origin //TODO: redox can't undestand this (got exit status 1) let mut command = Command::new("bash"); @@ -225,23 +236,25 @@ pub fn fetch(recipe_dir: &Path, recipe: &Recipe, logger: &PtyOut) -> Result, - /// The optional config to run as shallow fetch. Only use this for heavy git like "rust" - /// This will disable recipe autofetching because of its cost on git server + /// The optional config to clone with treeless clone. Default is true if "rev" added shallow_clone: Option, /// A list of patch files to apply to the source #[serde(default)] @@ -449,12 +448,9 @@ mod tests { Recipe { source: Some(SourceRecipe::Git { git: "https://gitlab.redox-os.org/redox-os/acid.git".to_string(), - upstream: None, branch: Some("master".to_string()), rev: Some("06344744d3d55a5ac9a62a6059cb363d40699bbc".to_string()), - patches: Vec::new(), - script: None, - shallow_clone: None, + ..Default::default() }), build: BuildRecipe::new(BuildKind::Cargo { package_path: None,