Reputation: 23
We can get all branches of a particular repository with the query mentioned here.
query {
repository(owner: "<userName>", name: "<repoName>") {
refs(first: 10, refPrefix: "refs/heads/",after:"<cursor>") {
edges {
node {
name
target {
... on Commit {
author {
name
email
user {
login
}
}
pushedDate
oid
}
}
}
}
}
}
}
But would it be possible for the names to be returned in a sorted order by pushedDate
( or any relevant dates ) . for eg if my repository has 2 branches ( branch 1
with pushdate as March 1
and branch 2
with pushDate as March 10
I want branch2
to be returned before branch 1
).
We can do that sorting manually but the issue is that my query is paginated , so this sort would just order only those branches in the current page.
Upvotes: 2
Views: 1459
Reputation: 313
Unfortunately I do not think this is possible. The only way you can order the branches is by ALPHABETICAL
e.g. refs(first: 10, refPrefix: "refs/heads/", orderBy: {field: ALPHABETICAL, direction: DESC}
However, assuming you do not have 1000s of branches perhaps you could, as you suggest, make all the paginated queries then order by pushedDate
. You can get 100 nodes at a time with pagination (first: 100
) so likely only a few queries to get all branches.
Upvotes: 1