pull: fix edge cases
Some checks failed
CI / build (push) Failing after 13m53s
CI / snap (push) Has been skipped

- Ubuntu does not have 'Launchpad/Code' repo edge case
- Vcs-Git field has a git command, not only an URL edge case
This commit is contained in:
2026-03-17 17:22:25 +01:00
parent dce39c9a84
commit 5ec675c20b
2 changed files with 35 additions and 4 deletions

View File

@@ -153,6 +153,14 @@ impl Iterator for DebianSources {
} }
} }
// Parse Vcs-Git field: it may contain just a URL, or URL followed by -b <branch>
// e.g., "https://salsa.debian.org/science-team/paraview.git -b debian/latest"
let vcs_git = fields.get("Vcs-Git").map(|vcs| {
// Split on whitespace and take the first part (the URL)
// The URL should not contain spaces, so this is safe
vcs.split_whitespace().next().unwrap_or(vcs).to_string()
});
Some(PackageStanza { Some(PackageStanza {
package: fields.get("Package").unwrap().to_string(), package: fields.get("Package").unwrap().to_string(),
version: fields.get("Version").unwrap().to_string(), version: fields.get("Version").unwrap().to_string(),
@@ -161,7 +169,7 @@ impl Iterator for DebianSources {
.get("Format") .get("Format")
.cloned() .cloned()
.unwrap_or_else(|| "1.0".to_string()), .unwrap_or_else(|| "1.0".to_string()),
vcs_git: fields.get("Vcs-Git").cloned(), vcs_git,
vcs_browser: fields.get("Vcs-Browser").cloned(), vcs_browser: fields.get("Vcs-Browser").cloned(),
files, files,
}) })

View File

@@ -504,14 +504,17 @@ pub async fn pull(
// Depending on target series, we pick target branch; if latest series is specified, // Depending on target series, we pick target branch; if latest series is specified,
// we target the development branch, i.e. the default branch // we target the development branch, i.e. the default branch
// Only use Ubuntu-specific branch naming if the VCS is from Launchpad
let is_launchpad_vcs = url.contains("launchpad.net");
let branch_name = if crate::distro_info::get_ordered_series_name(package_info.dist.as_str()) let branch_name = if crate::distro_info::get_ordered_series_name(package_info.dist.as_str())
.await?[0] .await?[0]
!= *series != *series
{ {
if package_info.dist == "ubuntu" { if package_info.dist == "ubuntu" && is_launchpad_vcs {
Some(format!("{}/{}", package_info.dist, series)) Some(format!("{}/{}", package_info.dist, series))
} else { } else {
// Debian does not have reliable branch naming... // Debian does not have reliable branch naming...
// Also, Ubuntu packages with salsa VCS don't have Ubuntu-specific branches
// For now, we skip that part and clone default // For now, we skip that part and clone default
// TODO: Inspect remote branches and tags for matches // TODO: Inspect remote branches and tags for matches
None None
@@ -615,18 +618,27 @@ mod tests {
let head = repo.head().unwrap(); let head = repo.head().unwrap();
let name = head.name().unwrap(); let name = head.name().unwrap();
// Check if the VCS is from Launchpad - only Launchpad has Ubuntu-specific branches
let is_launchpad_vcs = info
.preferred_vcs
.as_ref()
.map(|url| url.contains("launchpad.net"))
.unwrap_or(false);
if let Some(s) = series { if let Some(s) = series {
// The local branch should be named dist/series // The local branch should be named dist/series
// We skip debian for now as it does not have a reliable naming scheme // We skip debian for now as it does not have a reliable naming scheme
if info.dist == "ubuntu" { // Also skip Ubuntu packages with non-Launchpad VCS (e.g., salsa.debian.org)
if info.dist == "ubuntu" && is_launchpad_vcs {
assert_eq!(name, format!("refs/heads/{0}/{s}", info.dist)); assert_eq!(name, format!("refs/heads/{0}/{s}", info.dist));
} }
} else { } else {
// The local branch should be named ubuntu/devel for Ubuntu // The local branch should be named ubuntu/devel for Ubuntu
// Debian unfortunately does not have a reliable naming scheme // Debian unfortunately does not have a reliable naming scheme
// Also skip Ubuntu packages with non-Launchpad VCS
// Given that there was no series specified, and this is a test, // Given that there was no series specified, and this is a test,
// we require to have a distribution specified // we require to have a distribution specified
if dist.unwrap() == "ubuntu" { if dist.unwrap() == "ubuntu" && is_launchpad_vcs {
assert_eq!(name, "refs/heads/ubuntu/devel"); assert_eq!(name, "refs/heads/ubuntu/devel");
} }
} }
@@ -690,4 +702,15 @@ mod tests {
async fn test_pull_hello_ubuntu_latest_end_to_end() { async fn test_pull_hello_ubuntu_latest_end_to_end() {
test_pull_package_end_to_end("hello", None, Some("ubuntu"), None).await; test_pull_package_end_to_end("hello", None, Some("ubuntu"), None).await;
} }
/// Test for paraview - a package that has no Ubuntu Launchpad code,
/// only a debian salsa repo, even in Ubuntu.
/// Furthermore, paraview has a Vcs-Git value of:
/// Vcs-Git: https://salsa.debian.org/science-team/paraview.git -b debian/latest
/// Given that it is not only an url but also specifies a branch, it needs
/// special care, that this test ensures.
#[tokio::test]
async fn test_pull_paraview_ubuntu_end_to_end() {
test_pull_package_end_to_end("paraview", Some("noble"), None, None).await;
}
} }