MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / getVersionFromGit

Function getVersionFromGit

scripts/prepublish.ts:54–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52}
53
54async 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
73async function resolveVersion(): Promise<string> {
74 return getVersionFromEnvironment() ?? (await getVersionFromGit());

Callers 1

resolveVersionFunction · 0.85

Calls 2

normalizeVersionFunction · 0.85
getShellErrorMessageFunction · 0.85

Tested by

no test coverage detected