( ref: string, remoteNames: ReadonlyArray<string>, )
| 14 | } |
| 15 | |
| 16 | export function parseRemoteRefWithRemoteNames( |
| 17 | ref: string, |
| 18 | remoteNames: ReadonlyArray<string>, |
| 19 | ): { remoteRef: string; remoteName: string; branchName: string } | null { |
| 20 | const trimmedRef = ref.trim(); |
| 21 | if (trimmedRef.length === 0) { |
| 22 | return null; |
| 23 | } |
| 24 | |
| 25 | for (const remoteName of remoteNames) { |
| 26 | const remotePrefix = `${remoteName}/`; |
| 27 | if (!trimmedRef.startsWith(remotePrefix)) { |
| 28 | continue; |
| 29 | } |
| 30 | const branchName = trimmedRef.slice(remotePrefix.length).trim(); |
| 31 | if (branchName.length === 0) { |
| 32 | return null; |
| 33 | } |
| 34 | return { |
| 35 | remoteRef: trimmedRef, |
| 36 | remoteName, |
| 37 | branchName, |
| 38 | }; |
| 39 | } |
| 40 | |
| 41 | return null; |
| 42 | } |
| 43 | |
| 44 | export function extractBranchNameFromRemoteRef( |
| 45 | ref: string, |
no outgoing calls
no test coverage detected