(git = simpleGit())
| 9 | } |
| 10 | |
| 11 | export async function getGitDefaultBranch(git = simpleGit()): Promise<string> { |
| 12 | try { |
| 13 | const head = await git.revparse(['--abbrev-ref', 'origin/HEAD']); |
| 14 | return head.replace(/^origin\//, ''); |
| 15 | } catch (error) { |
| 16 | logger.warn( |
| 17 | `Failed to get the default Git branch, falling back to main - ${stringifyError(error)}`, |
| 18 | ); |
| 19 | return 'main'; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | export function formatGitPath(filePath: string, gitRoot: string): string { |
| 24 | const absolutePath = path.isAbsolute(filePath) |
no test coverage detected