Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Github BranchService only returns 1 page of results #152

@psigourney

Description

@psigourney

val branches = with(githubFeignClient) {
getOwnerRepoFromUrl(pipeline.url).let { (owner, repo) ->
retrieveBranches(
pipeline.credential,
owner,
repo,
)
}
}

Github API Docs: https://docs.github.com/en/rest/branches/branches#list-branches
Based on the GH API, only the first 30 branches will be returned by the BranchService.

fun getNewRuns(pipeline: PipelineConfiguration, emitCb: (SyncProgress) -> Unit): MutableList<GithubActionsRun> {
val latestTimestamp = getLatestBuildTimeStamp(pipeline)
val newRuns = runService.syncRunsByPage(pipeline, latestTimestamp, emitCb)
val branches = branchService.retrieveBranches(pipeline)
return newRuns.filter { branches.contains(it.branch) } as MutableList<GithubActionsRun>
}

I'm not really sure why we're pulling the branches and filtering on them to begin with (if a run was executed on a specific branch, then that branch was later deleted, we'd still want to capture the run, right?), but if the branch filter is required (could someone reply with an explanation?), it might make sense to apply some pagination logic to the BranchService, similar to the logic used in syncRunsByPage:

https://github.com/thoughtworks/metrik/blob/main/backend/src/main/kotlin/metrik/project/domain/service/githubactions/RunService.kt#L19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions