* Get the versions for generated packages. The stamped versions are always based * on the workspace version. Relying on tags is less reliable because tags can be * modified easily in an untracked/uncontrolled way, and are less predictable with * regards to the source control revision currently be
( git: GitClient, mode: EnvStampMode, )
| 60 | * In snapshot mode, we will include the current SHA along with the workspace version. |
| 61 | */ |
| 62 | function getSCMVersions( |
| 63 | git: GitClient, |
| 64 | mode: EnvStampMode, |
| 65 | ): {version: string; experimentalVersion: string} { |
| 66 | const version = getVersionFromWorkspacePackageJson(git).format(); |
| 67 | const experimentalVersion = createExperimentalSemver(version).format(); |
| 68 | |
| 69 | if (mode === 'release') { |
| 70 | return { |
| 71 | version, |
| 72 | experimentalVersion, |
| 73 | }; |
| 74 | } |
| 75 | |
| 76 | const headShaAbbreviated = getCurrentSha(git).slice(0, 7); |
| 77 | const localChanges = hasLocalChanges(git) ? '-with-local-changes' : ''; |
| 78 | |
| 79 | return { |
| 80 | version: `${version}+sha-${headShaAbbreviated}${localChanges}`, |
| 81 | experimentalVersion: `${experimentalVersion}+sha-${headShaAbbreviated}${localChanges}`, |
| 82 | }; |
| 83 | } |
| 84 | |
| 85 | /** Get the current SHA of HEAD. */ |
| 86 | function getCurrentSha(git: GitClient) { |
no test coverage detected