You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
query GetBranches($owner: String!, $name: String!) {
repository(name: $name, owner: $owner) {
id
defaultBranchRef {
name
id
}
refs(first: 100, refPrefix: "refs/heads/") {
nodes {
name
+ associatedPullRequests(+ first: 5, # fetch some more in case user opened PR against their own repo, or opened a new PR because previous one is closed+ ) {+ nodes {+ title+ url+ state+ repository {+ nameWithOwner # filter this by "microsoft/winget-pkgs"+ }+ }+ }
}
}
}
}
You can pass the wanted states as a variable (as long as people don't re-open PRs with the same branch), or just check the state property in the result like how it's currently done. Edit: You should keep the current behavior. Filtering it in the query might cause false positives when the user opens a new PR when the previous one is closed unmerged.
To be safe, you should also fetch more than 1 PR per branch and filter repository.name_with_owner by microsoft/winget-pkgs. I sometimes mistakenly open pull requests again my own fork repo, especially when it's made through the web UI, and I think other people sometimes do this too. If we use first: 1, we might never get the correct PR against the microsoft repo. (Edit: it might make sense to make sure PRs against other repos are closed/merged too)
In fact this also fixes a bug caused by fetching PR by branch name instead of branch ID. I once reused a deleted branch name when manually creating a PR to modify a manifest I created, but Komac thinks this branch is merged and listed it in cleanup. By fetching associatedPullRequests, this issue is resolved automatically.
The text was updated successfully, but these errors were encountered:
What would you like to see changed/added?
Currently,
cleanup
command sends one API request per branch:Komac/src/commands/cleanup.rs
Lines 67 to 78 in 5ab284a
Actually you can get the information within the get-branches request:
Komac/src/commands/cleanup.rs
Lines 46 to 48 in 5ab284a
Here's an example of the GraphQL query:
You can pass the wantedEdit: You should keep the current behavior. Filtering it in the query might cause false positives when the user opens a new PR when the previous one is closed unmerged.states
as a variable (as long as people don't re-open PRs with the same branch), or just check thestate
property in the result like how it's currently done.To be safe, you should also fetch more than 1 PR per branch and filter
repository.name_with_owner
bymicrosoft/winget-pkgs
. I sometimes mistakenly open pull requests again my own fork repo, especially when it's made through the web UI, and I think other people sometimes do this too. If we usefirst: 1
, we might never get the correct PR against themicrosoft
repo. (Edit: it might make sense to make sure PRs against other repos are closed/merged too)In fact this also fixes a bug caused by fetching PR by branch name instead of branch ID. I once reused a deleted branch name when manually creating a PR to modify a manifest I created, but Komac thinks this branch is merged and listed it in
cleanup
. By fetchingassociatedPullRequests
, this issue is resolved automatically.The text was updated successfully, but these errors were encountered: