Fix changing git rev cache

This commit is contained in:
Wildan M 2026-04-01 10:29:01 +07:00
parent a4be504b40
commit 0f7323e47a
No known key found for this signature in database
GPG Key ID: 01AC53185C679C79
2 changed files with 7 additions and 2 deletions

View File

@ -238,14 +238,18 @@ 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
if rev.is_some() {
if !detached_rev {
false
} else if let Some(rev) = rev
&& let Ok(exp_rev) = get_git_tag_rev(&source_dir, &rev)
{
exp_rev == head_rev
} else {
false
}
} else if detached_rev {
false
} else {
let (_, remote_branch, remote_name, remote_url) =
get_git_remote_tracking(&source_dir)?;

View File

@ -298,6 +298,7 @@ pub fn get_git_tag_rev(dir: &PathBuf, tag: &str) -> Result<String> {
}
pub fn get_git_ref_entry(dir: &PathBuf, entry: &str) -> Result<String> {
// 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() {