pull: fix edge cases
Some checks failed
CI / build (push) Failing after 14m9s
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 15:06:22 +01:00
parent dce39c9a84
commit 338ffc5ac7
2 changed files with 24 additions and 2 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 {
package: fields.get("Package").unwrap().to_string(),
version: fields.get("Version").unwrap().to_string(),
@@ -161,7 +169,7 @@ impl Iterator for DebianSources {
.get("Format")
.cloned()
.unwrap_or_else(|| "1.0".to_string()),
vcs_git: fields.get("Vcs-Git").cloned(),
vcs_git,
vcs_browser: fields.get("Vcs-Browser").cloned(),
files,
})

View File

@@ -504,14 +504,17 @@ pub async fn pull(
// Depending on target series, we pick target branch; if latest series is specified,
// 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())
.await?[0]
!= *series
{
if package_info.dist == "ubuntu" {
if package_info.dist == "ubuntu" && is_launchpad_vcs {
Some(format!("{}/{}", package_info.dist, series))
} else {
// 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
// TODO: Inspect remote branches and tags for matches
None
@@ -690,4 +693,15 @@ mod tests {
async fn test_pull_hello_ubuntu_latest_end_to_end() {
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;
}
}