@@ -17,15 +17,14 @@ import { isNonEmptyString } from '@socketsecurity/registry/lib/strings'
1717
1818import {
1919 createSocketBranchParser ,
20- genericSocketBranchParser ,
20+ getSocketBranchPattern ,
2121 getSocketPullRequestBody ,
2222 getSocketPullRequestTitle ,
2323} from './git.mts'
2424import constants from '../../constants.mts'
2525import { safeStatsSync } from '../../utils/fs.mts'
2626import { getPurlObject } from '../../utils/purl.mts'
2727
28- import type { SocketBranchParseResult } from './git.mts'
2928import type { SocketArtifact } from '../../utils/alert/artifact.mts'
3029import type { components } from '@octokit/openapi-types'
3130import type { OctokitResponse } from '@octokit/types'
@@ -131,7 +130,6 @@ export type PrMatch = {
131130 headRefName : string
132131 mergeStateStatus : GQL_MERGE_STATE_STATUS
133132 number : number
134- parsedBranch : SocketBranchParseResult
135133 state : GQL_PR_STATE
136134 title : string
137135}
@@ -312,6 +310,7 @@ async function getSocketPrsWithContext(
312310 __proto__ : null ,
313311 ...options ,
314312 } as SocketPrsOptions
313+ const branchPattern = getSocketBranchPattern ( options )
315314 const checkAuthor = isNonEmptyString ( author )
316315 const octokit = getOctokit ( )
317316 const octokitGraphql = getOctokitGraphql ( )
@@ -373,8 +372,8 @@ async function getSocketPrsWithContext(
373372 const node = nodes [ i ] !
374373 const login = node . author ?. login
375374 const matchesAuthor = checkAuthor ? login === author : true
376- const parsedBranch = genericSocketBranchParser ( node . headRefName )
377- if ( matchesAuthor && parsedBranch ) {
375+ const matchesBranch = branchPattern . test ( node . headRefName )
376+ if ( matchesAuthor && matchesBranch ) {
378377 contextualMatches . push ( {
379378 context : {
380379 apiType : 'graphql' ,
@@ -387,7 +386,6 @@ async function getSocketPrsWithContext(
387386 match : {
388387 ...node ,
389388 author : login ?? '<unknown>' ,
390- parsedBranch,
391389 } ,
392390 } )
393391 }
@@ -423,8 +421,8 @@ async function getSocketPrsWithContext(
423421 const login = pr . user ?. login
424422 const headRefName = pr . head . ref
425423 const matchesAuthor = checkAuthor ? login === author : true
426- const parsedBranch = genericSocketBranchParser ( headRefName )
427- if ( matchesAuthor && parsedBranch ) {
424+ const matchesBranch = branchPattern . test ( headRefName )
425+ if ( matchesAuthor && matchesBranch ) {
428426 // Upper cased mergeable_state is equivalent to mergeStateStatus.
429427 // https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request
430428 const mergeStateStatus = ( pr . mergeable_state ?. toUpperCase ?.( ) ??
@@ -450,7 +448,6 @@ async function getSocketPrsWithContext(
450448 headRefName,
451449 mergeStateStatus,
452450 number : pr . number ,
453- parsedBranch,
454451 state,
455452 title : pr . title ,
456453 } ,
0 commit comments