Skip to content

Commit 1dd59fc

Browse files
committed
Avoids partial matches w/ associated GH branch PRs
1 parent 657c71d commit 1dd59fc

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
4444
- Fixes [#2252](https://github.com/gitkraken/vscode-gitlens/issues/2252) - "Copy As"/"Copy Remote File Url" copies %23 instead of # in case of Gitea — thanks to [PR #2603](https://github.com/gitkraken/vscode-gitlens/pull/2603) by WofWca ([@WofWca](https://github.com/WofWca))
4545
- Fixes [#2582](https://github.com/gitkraken/vscode-gitlens/issues/2582) - _Visual File History_ background color when in a panel
4646
- Fixes [#2609](https://github.com/gitkraken/vscode-gitlens/issues/2609) - If you check out a branch that is hidden, GitLens should show the branch still
47-
- Fixes tooltips sometimes failing to show in _Commit Graph_ rows when the Date column is hidden
4847
- Fixes [#2595](https://github.com/gitkraken/vscode-gitlens/issues/2595) - Error when stashing changes
48+
- Fixes tooltips sometimes failing to show in _Commit Graph_ rows when the Date column is hidden
49+
- Fixes an issue with incorrectly showing associated pull requests with branches that are partial matches of the true branch the pull request is associated with
4950

5051
## [13.4.0] - 2023-03-16
5152

src/plus/github/github.ts

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -554,13 +554,14 @@ export class GitHubApi implements Disposable {
554554
interface QueryResult {
555555
repository:
556556
| {
557-
refs: {
558-
nodes: {
559-
associatedPullRequests?: {
560-
nodes?: GitHubPullRequest[];
561-
};
562-
}[];
563-
};
557+
ref:
558+
| {
559+
associatedPullRequests?: {
560+
nodes?: GitHubPullRequest[];
561+
};
562+
}
563+
| null
564+
| undefined;
564565
}
565566
| null
566567
| undefined;
@@ -576,27 +577,25 @@ export class GitHubApi implements Disposable {
576577
$avatarSize: Int
577578
) {
578579
repository(name: $repo, owner: $owner) {
579-
refs(query: $branch, refPrefix: "refs/heads/", first: 1) {
580-
nodes {
581-
associatedPullRequests(first: $limit, orderBy: {field: UPDATED_AT, direction: DESC}, states: $include) {
582-
nodes {
583-
author {
580+
ref(qualifiedName: $branch) {
581+
associatedPullRequests(first: $limit, orderBy: {field: UPDATED_AT, direction: DESC}, states: $include) {
582+
nodes {
583+
author {
584+
login
585+
avatarUrl(size: $avatarSize)
586+
url
587+
}
588+
permalink
589+
number
590+
title
591+
state
592+
updatedAt
593+
closedAt
594+
mergedAt
595+
repository {
596+
isFork
597+
owner {
584598
login
585-
avatarUrl(size: $avatarSize)
586-
url
587-
}
588-
permalink
589-
number
590-
title
591-
state
592-
updatedAt
593-
closedAt
594-
mergedAt
595-
repository {
596-
isFork
597-
owner {
598-
login
599-
}
600599
}
601600
}
602601
}
@@ -613,15 +612,15 @@ export class GitHubApi implements Disposable {
613612
...options,
614613
owner: owner,
615614
repo: repo,
616-
branch: branch,
615+
branch: `refs/heads/${branch}`,
617616
// Since GitHub sort doesn't seem to really work, look for a max of 10 PRs and then sort them ourselves
618617
limit: 10,
619618
},
620619
scope,
621620
);
622621

623622
// If the pr is not from a fork, keep it e.g. show root pr's on forks, otherwise, ensure the repo owners match
624-
const prs = rsp?.repository?.refs.nodes[0]?.associatedPullRequests?.nodes?.filter(
623+
const prs = rsp?.repository?.ref?.associatedPullRequests?.nodes?.filter(
625624
pr => pr != null && (!pr.repository.isFork || pr.repository.owner.login === owner),
626625
);
627626
if (prs == null || prs.length === 0) return undefined;

0 commit comments

Comments
 (0)