()
| 52 | } |
| 53 | |
| 54 | async function getVersionFromGit(): Promise<string> { |
| 55 | try { |
| 56 | return normalizeVersion(await $`git describe --tags --always`.text()); |
| 57 | } catch (error) { |
| 58 | const message = getShellErrorMessage(error); |
| 59 | |
| 60 | if (message.includes('detected dubious ownership')) { |
| 61 | throw new Error( |
| 62 | 'Git refused to read repository metadata because this checkout is not marked as safe. Configure safe.directory in CI or provide RELEASE_VERSION/GITHUB_REF_NAME.', |
| 63 | { cause: error }, |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | throw new Error(`Unable to resolve publish version from git: ${message}`, { |
| 68 | cause: error, |
| 69 | }); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | async function resolveVersion(): Promise<string> { |
| 74 | return getVersionFromEnvironment() ?? (await getVersionFromGit()); |
no test coverage detected