Skip to content

branch crawler does not paginate #8

@wucke13

Description

@wucke13

When looking for a branch with a given name, we might fail to find it if the branch is not on the first page. The default page size seems to be 100, so if there is more than 100 branches, it becomes more an more likely that we don't find the branch we are looking for.

sysml-v2-sql/src/fetch.rs

Lines 166 to 190 in c33aa38

CommitSelector::BranchName { branch_name } => {
debug!("searching for branch by the name {branch_name:?}");
let url = browser.absolute_url(format!("projects/{project_id}/branches"));
let branches: Vec<Branch> = browser.http_get(url).await?.json().await?;
trace!("found the following branches:\n{branches:#?}");
let matching_branches: Vec<&Branch> = branches
.iter()
.filter(|p| p.name.starts_with(branch_name))
.collect();
if matching_branches.is_empty() {
error!("no branch matched the specified name {branch_name:?}");
info!("the following branch where found:\n{branches:#?}");
bail!("error finding any matching branch");
} else if matching_branches.len() > 1 {
error!("multiple branches matched the specified name {branch_name:?}, please be more specific");
info!("the following branches where found:\n{matching_branches:#?}");
bail!("error finding exactly one matching branch");
}
matching_branches.first().unwrap().head.id.to_owned()
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions