@@ -1694,11 +1694,57 @@ current branch '${currentBranch}' ahead of base '${baseRef}'.`,
16941694 if ( remoteProject ) {
16951695 const connId = remoteProject . sshConnectionId ;
16961696 const fields = 'bucket,completedAt,description,event,link,name,startedAt,state,workflow' ;
1697- const checksResult = await remoteGitService . execGh (
1698- connId ,
1699- taskPath ,
1700- `pr checks --json ${ fields } `
1701- ) ;
1697+
1698+ // Detect fork on remote: find PR in parent repo if applicable
1699+ let prRef : string | null = null ;
1700+ let remoteParentRepo : string | null = null ;
1701+ let remoteChecksApiRepo = 'repos/{owner}/{repo}' ;
1702+ let remoteHeadRefOidCmd = "pr view --json headRefOid --jq '.headRefOid'" ;
1703+ try {
1704+ const repoResult = await remoteGitService . execGh (
1705+ connId ,
1706+ taskPath ,
1707+ 'repo view --json owner,parent'
1708+ ) ;
1709+ const repoData = repoResult . stdout . trim ( ) ? JSON . parse ( repoResult . stdout . trim ( ) ) : null ;
1710+ const parentOwner = repoData ?. parent ?. owner ?. login ;
1711+ const parentName = repoData ?. parent ?. name ;
1712+ const parentRepo = parentOwner && parentName ? `${ parentOwner } /${ parentName } ` : null ;
1713+ if ( parentRepo ) {
1714+ const branchResult = await remoteGitService . execGit (
1715+ connId ,
1716+ taskPath ,
1717+ 'branch --show-current'
1718+ ) ;
1719+ const currentBranch = branchResult . stdout . trim ( ) ;
1720+ if ( currentBranch ) {
1721+ const listResult = await remoteGitService . execGh (
1722+ connId ,
1723+ taskPath ,
1724+ `pr list --head ${ quoteGhArg ( currentBranch ) } --repo ${ quoteGhArg ( parentRepo ) } --state open --json number,headRefOid,headRepositoryOwner --limit 10`
1725+ ) ;
1726+ const forkOwnerLogin = repoData ?. owner ?. login ;
1727+ const listData = listResult . stdout . trim ( ) ? JSON . parse ( listResult . stdout . trim ( ) ) : [ ] ;
1728+ const matched = forkOwnerLogin
1729+ ? listData . find ( ( pr : any ) => pr ?. headRepositoryOwner ?. login === forkOwnerLogin )
1730+ : listData [ 0 ] ;
1731+ if ( matched ) {
1732+ prRef = String ( matched . number ) ;
1733+ remoteParentRepo = parentRepo ;
1734+ remoteChecksApiRepo = `repos/${ parentRepo } ` ;
1735+ remoteHeadRefOidCmd = `pr view ${ prRef } --repo ${ quoteGhArg ( parentRepo ) } --json headRefOid --jq '.headRefOid'` ;
1736+ }
1737+ }
1738+ }
1739+ } catch {
1740+ // Not a fork or detection failed — proceed with default behavior
1741+ }
1742+
1743+ const checksCmd =
1744+ prRef && remoteParentRepo
1745+ ? `pr checks ${ prRef } --repo ${ quoteGhArg ( remoteParentRepo ) } --json ${ fields } `
1746+ : `pr checks --json ${ fields } ` ;
1747+ const checksResult = await remoteGitService . execGh ( connId , taskPath , checksCmd ) ;
17021748 if ( checksResult . exitCode !== 0 ) {
17031749 const msg = checksResult . stderr || '' ;
17041750 if ( / n o p u l l r e q u e s t s ? f o u n d / i. test ( msg ) || / n o t f o u n d / i. test ( msg ) ) {
@@ -1713,17 +1759,13 @@ current branch '${currentBranch}' ahead of base '${baseRef}'.`,
17131759
17141760 // Fetch html_url from API
17151761 try {
1716- const shaResult = await remoteGitService . execGh (
1717- connId ,
1718- taskPath ,
1719- "pr view --json headRefOid --jq '.headRefOid'"
1720- ) ;
1762+ const shaResult = await remoteGitService . execGh ( connId , taskPath , remoteHeadRefOidCmd ) ;
17211763 const sha = shaResult . stdout . trim ( ) ;
17221764 if ( sha ) {
17231765 const apiResult = await remoteGitService . execGh (
17241766 connId ,
17251767 taskPath ,
1726- `api repos/{owner}/{repo }/commits/${ sha } /check-runs --jq '.check_runs | map({name: .name, html_url: .html_url}) | .[]'`
1768+ `api ${ remoteChecksApiRepo } /commits/${ sha } /check-runs --jq '.check_runs | map({name: .name, html_url: .html_url}) | .[]'`
17271769 ) ;
17281770 const urlMap = new Map < string , string > ( ) ;
17291771 for ( const line of apiResult . stdout . trim ( ) . split ( '\n' ) ) {
0 commit comments