@@ -82,20 +82,20 @@ function parseRepositoryNameFromPullRequestUrl(url: string): string | null {
8282}
8383
8484function resolveHeadRepositoryNameWithOwner (
85- pullRequest : ResolvedPullRequest & PullRequestHeadRemoteInfo ,
85+ pr : PullRequestHeadRemoteInfo & { url : string } ,
8686) : string | null {
87- const explicitRepository = pullRequest . headRepositoryNameWithOwner ?. trim ( ) ?? "" ;
88- if ( explicitRepository . length > 0 ) {
87+ const explicitRepository = normalizeOptionalString ( pr . headRepositoryNameWithOwner ) ;
88+ if ( explicitRepository ) {
8989 return explicitRepository ;
9090 }
9191
92- if ( ! pullRequest . isCrossRepository ) {
92+ if ( ! pr . isCrossRepository ) {
9393 return null ;
9494 }
9595
96- const ownerLogin = pullRequest . headRepositoryOwnerLogin ?. trim ( ) ?? "" ;
97- const repositoryName = parseRepositoryNameFromPullRequestUrl ( pullRequest . url ) ;
98- if ( ownerLogin . length === 0 || ! repositoryName ) {
96+ const ownerLogin = normalizeOptionalString ( pr . headRepositoryOwnerLogin ) ;
97+ const repositoryName = parseRepositoryNameFromPullRequestUrl ( pr . url ) ;
98+ if ( ! ownerLogin || ! repositoryName ) {
9999 return null ;
100100 }
101101
@@ -153,27 +153,6 @@ function normalizeOptionalOwnerLogin(value: string | null | undefined): string |
153153 return normalized ? normalized . toLowerCase ( ) : null ;
154154}
155155
156- function resolvePullRequestHeadRepositoryNameWithOwner (
157- pr : PullRequestHeadRemoteInfo & { url : string } ,
158- ) {
159- const explicitRepository = normalizeOptionalString ( pr . headRepositoryNameWithOwner ) ;
160- if ( explicitRepository ) {
161- return explicitRepository ;
162- }
163-
164- if ( ! pr . isCrossRepository ) {
165- return null ;
166- }
167-
168- const ownerLogin = normalizeOptionalString ( pr . headRepositoryOwnerLogin ) ;
169- const repositoryName = parseRepositoryNameFromPullRequestUrl ( pr . url ) ;
170- if ( ! ownerLogin || ! repositoryName ) {
171- return null ;
172- }
173-
174- return `${ ownerLogin } /${ repositoryName } ` ;
175- }
176-
177156function matchesBranchHeadContext (
178157 pr : PullRequestInfo ,
179158 headContext : Pick <
@@ -192,7 +171,7 @@ function matchesBranchHeadContext(
192171 normalizeOptionalOwnerLogin ( headContext . headRepositoryOwnerLogin ) ??
193172 parseRepositoryOwnerLogin ( expectedHeadRepository ) ;
194173 const prHeadRepository = normalizeOptionalRepositoryNameWithOwner (
195- resolvePullRequestHeadRepositoryNameWithOwner ( pr ) ,
174+ resolveHeadRepositoryNameWithOwner ( pr ) ,
196175 ) ;
197176 const prHeadOwner =
198177 normalizeOptionalOwnerLogin ( pr . headRepositoryOwnerLogin ) ??
@@ -857,10 +836,18 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
857836 result : Pick < GitRunStackedActionResult , "action" | "branch" | "commit" | "push" | "pr" > ,
858837 ) {
859838 const summary = summarizeGitActionResult ( result ) ;
860- let latestOpenPr : PullRequestInfo | null = null ;
861839 let currentBranchIsDefault = false ;
862840
863- if ( result . action !== "commit" ) {
841+ const explicitResultPr =
842+ ( result . pr . status === "created" || result . pr . status === "opened_existing" ) && result . pr . url
843+ ? {
844+ url : result . pr . url ,
845+ state : "open" as const ,
846+ }
847+ : null ;
848+
849+ let latestOpenPr : PullRequestInfo | null = null ;
850+ if ( result . action !== "commit" && ! explicitResultPr ) {
864851 const finalStatus = yield * gitCore . statusDetails ( cwd ) ;
865852 if ( finalStatus . branch ) {
866853 latestOpenPr = yield * findLatestPr ( cwd , {
@@ -878,14 +865,7 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
878865 }
879866 }
880867
881- const explicitResultPr =
882- ( result . pr . status === "created" || result . pr . status === "opened_existing" ) && result . pr . url
883- ? {
884- url : result . pr . url ,
885- state : "open" as const ,
886- }
887- : null ;
888- const openPr = latestOpenPr ?? explicitResultPr ;
868+ const openPr = explicitResultPr ?? latestOpenPr ;
889869
890870 const cta =
891871 result . action === "commit" && result . commit . status === "created"
0 commit comments