Merge branch 'tag-cosmic' into 'master'

Use tagged cosmic rev, fix updating git rev

See merge request redox-os/redox!2040
This commit is contained in:
Jeremy Soller 2026-04-04 13:19:57 -06:00
commit 352a9e76ef
7 changed files with 47 additions and 33 deletions

View File

@ -1,6 +1,6 @@
[source]
git = "https://github.com/pop-os/cosmic-edit.git"
branch = "master"
rev = "epoch-1.0.8"
[build]
template = "custom"

View File

@ -1,6 +1,6 @@
[source]
git = "https://github.com/pop-os/cosmic-files.git"
branch = "master"
rev = "epoch-1.0.8"
[build]
template = "custom"

View File

@ -1,6 +1,6 @@
[source]
git = "https://github.com/pop-os/cosmic-reader.git"
branch = "master"
rev = "epoch-1.0.8"
[build]
template = "custom"

View File

@ -1,6 +1,6 @@
[source]
git = "https://github.com/pop-os/cosmic-store.git"
branch = "master"
rev = "epoch-1.0.8"
[build]
template = "custom"

View File

@ -1,6 +1,6 @@
[source]
git = "https://github.com/pop-os/cosmic-term.git"
branch = "master"
rev = "epoch-1.0.8"
[build]
template = "custom"

View File

@ -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,
}
};

View File

@ -298,15 +298,21 @@ 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() {
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());
}
}