( thread: Thread, message: Message )
| 37 | function parseGitHubRepositoryFullName(id: string | undefined): string | null { |
| 38 | if (!id) return null; |
| 39 | |
| 40 | const match = id.match(/^github:([^/]+\/[^:]+)(?::|$)/); |
| 41 | if (!match) return null; |
| 42 | |
| 43 | return match[1] ?? null; |
| 44 | } |
| 45 | |
| 46 | export function getGitHubRepositoryReference( |
| 47 | thread: Thread, |
| 48 | message?: Message |
| 49 | ): GitHubRepositoryReference { |
| 50 | const { repository } = (message as Message<Partial<GitHubRawMessage>> | undefined)?.raw ?? {}; |
| 51 | |
| 52 | return { |
| 53 | id: repository?.id ?? null, |
| 54 | fullName: |
| 55 | repository?.full_name ?? |
| 56 | parseGitHubRepositoryFullName(thread.id) ?? |
| 57 | parseGitHubRepositoryFullName(thread.channelId), |
no test coverage detected