diff --git a/recipes/tools/cosmic-edit/recipe.toml b/recipes/tools/cosmic-edit/recipe.toml index bb813328..f3f1341a 100644 --- a/recipes/tools/cosmic-edit/recipe.toml +++ b/recipes/tools/cosmic-edit/recipe.toml @@ -1,6 +1,6 @@ [source] git = "https://github.com/pop-os/cosmic-edit.git" -branch = "master" +rev = "epoch-1.0.8" [build] template = "custom" diff --git a/recipes/tools/cosmic-files/recipe.toml b/recipes/tools/cosmic-files/recipe.toml index 7804f421..a1b30a25 100644 --- a/recipes/tools/cosmic-files/recipe.toml +++ b/recipes/tools/cosmic-files/recipe.toml @@ -1,6 +1,6 @@ [source] git = "https://github.com/pop-os/cosmic-files.git" -branch = "master" +rev = "epoch-1.0.8" [build] template = "custom" diff --git a/recipes/tools/cosmic-reader/recipe.toml b/recipes/tools/cosmic-reader/recipe.toml index 34e39227..f0e524df 100644 --- a/recipes/tools/cosmic-reader/recipe.toml +++ b/recipes/tools/cosmic-reader/recipe.toml @@ -1,6 +1,6 @@ [source] git = "https://github.com/pop-os/cosmic-reader.git" -branch = "master" +rev = "epoch-1.0.8" [build] template = "custom" diff --git a/recipes/tools/cosmic-store/recipe.toml b/recipes/tools/cosmic-store/recipe.toml index 3c57d1ef..2996bd8a 100644 --- a/recipes/tools/cosmic-store/recipe.toml +++ b/recipes/tools/cosmic-store/recipe.toml @@ -1,6 +1,6 @@ [source] git = "https://github.com/pop-os/cosmic-store.git" -branch = "master" +rev = "epoch-1.0.8" [build] template = "custom" diff --git a/recipes/tools/cosmic-term/recipe.toml b/recipes/tools/cosmic-term/recipe.toml index 21bf0884..c9228045 100644 --- a/recipes/tools/cosmic-term/recipe.toml +++ b/recipes/tools/cosmic-term/recipe.toml @@ -1,6 +1,6 @@ [source] git = "https://github.com/pop-os/cosmic-term.git" -branch = "master" +rev = "epoch-1.0.8" [build] template = "custom" diff --git a/src/cook/fetch.rs b/src/cook/fetch.rs index c06fd83e..50aab92b 100644 --- a/src/cook/fetch.rs +++ b/src/cook/fetch.rs @@ -251,35 +251,43 @@ pub fn fetch(recipe: &CookRecipe, check_source: bool, logger: &PtyOut) -> Result run_command(command, logger)?; let (head_rev, detached_rev) = get_git_head_rev(&source_dir)?; - if detached_rev { - if let Some(rev) = rev - && let Ok(exp_rev) = get_git_tag_rev(&source_dir, &rev) - { - exp_rev == head_rev - } else { - false - } - } else { - let (_, remote_branch, remote_name, remote_url) = - get_git_remote_tracking(&source_dir)?; - // TODO: how to get default branch and compare it here? - if let Some(branch) = branch - && branch != &remote_branch - { - false - } else if remote_name != "origin" { - false - } else if &remote_url != chop_dot_git(git) { - false - } else { - match get_git_fetch_rev(&source_dir, &remote_url, &remote_branch) { - Ok(fetch_rev) => fetch_rev == head_rev, - Err(e) => { - log_to_pty!(logger, "{}", e); + match (rev, detached_rev) { + (Some(rev), true) => { + if let Ok(exp_rev) = get_git_tag_rev(&source_dir, &rev) { + exp_rev == head_rev + } else { + let mut command = Command::new("git"); + command.arg("-C").arg(&source_dir); + command.arg("gc"); + run_command(command, logger)?; + if let Ok(exp_rev) = get_git_tag_rev(&source_dir, &rev) { + exp_rev == head_rev + } else { false } } } + (None, false) => { + let (_, remote_branch, remote_name, remote_url) = + get_git_remote_tracking(&source_dir)?; + // TODO: how to get default branch and compare it here? + if let Some(branch) = branch + && branch != &remote_branch + { + false + } else if remote_name != "origin" || &remote_url != chop_dot_git(git) { + false + } else { + match get_git_fetch_rev(&source_dir, &remote_url, &remote_branch) { + Ok(fetch_rev) => fetch_rev == head_rev, + Err(e) => { + log_to_pty!(logger, "{}", e); + false + } + } + } + } + _ => false, } }; diff --git a/src/cook/fs.rs b/src/cook/fs.rs index 684fbc61..f53b623c 100644 --- a/src/cook/fs.rs +++ b/src/cook/fs.rs @@ -298,15 +298,21 @@ pub fn get_git_tag_rev(dir: &PathBuf, tag: &str) -> Result { } pub fn get_git_ref_entry(dir: &PathBuf, entry: &str) -> Result { + // https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery let git_refs = dir.join(".git/packed-refs"); let refs_str = read_to_string(&git_refs)?; - for line in refs_str.lines() { + let mut lines = refs_str.lines(); + while let Some(line) = lines.next() { if line.contains(entry) { - let sha = line + let mut sha = line .split_whitespace() .next() .ok_or_else(wrap_other_err!("Packed-refs line is malformed"))?; - + if let Some(next_line) = lines.next() { + if next_line.starts_with('^') { + sha = &next_line[1..]; + } + } return Ok(sha.to_string()); } }