mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
e3e286bd01
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
30 lines
943 B
JavaScript
30 lines
943 B
JavaScript
import semver from 'semver';
|
|
import shell from 'shelljs';
|
|
import simpleGit from 'simple-git';
|
|
|
|
const GIT_MINIMUM_VERSION = '2.33.0';
|
|
const git = simpleGit();
|
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
(async () => {
|
|
try {
|
|
const regex = /\d+\.\d+\.\d+/;
|
|
const stdout = await git.raw('--version');
|
|
const [gitVersion] = regex.exec(stdout) ?? [];
|
|
if (!gitVersion || semver.lt(gitVersion, GIT_MINIMUM_VERSION)) {
|
|
if (process.env.CI) {
|
|
shell.echo(
|
|
`::error ::Minimum Git version ${GIT_MINIMUM_VERSION} is required, found version '${gitVersion}'.`
|
|
);
|
|
} else {
|
|
throw new Error(
|
|
`Minimum Git version ${GIT_MINIMUM_VERSION} is required, found version '${gitVersion}'.`
|
|
);
|
|
}
|
|
}
|
|
shell.echo('Found git version: ', gitVersion);
|
|
process.exit(0);
|
|
} catch (err) {
|
|
shell.echo('ERROR:', err.message);
|
|
process.exit(1);
|
|
}
|
|
})();
|