mirror of
https://github.com/tiktok/sparo.git
synced 2024-11-14 19:35:12 -05:00
feat: increase the minimal supported git version
This commit is contained in:
parent
12ddfb4710
commit
379e5be367
3 changed files with 15 additions and 6 deletions
|
@ -21,7 +21,9 @@ export class SparoCICommandLine {
|
|||
telemetryService.setCollectTelemetryFunction(launchOptions.collectTelemetryAsync);
|
||||
}
|
||||
|
||||
GitVersionCompatibility.ensureGitVersion();
|
||||
if (GitVersionCompatibility.reportGitRequiredVersion()) {
|
||||
process.exit(1);
|
||||
}
|
||||
SparoStartupBanner.logBanner({
|
||||
callerPackageJson: launchOptions.callerPackageJson
|
||||
});
|
||||
|
|
|
@ -22,7 +22,9 @@ export class SparoCommandLine {
|
|||
telemetryService.setCollectTelemetryFunction(launchOptions.collectTelemetryAsync);
|
||||
}
|
||||
|
||||
GitVersionCompatibility.ensureGitVersion();
|
||||
if (GitVersionCompatibility.reportGitRequiredVersion()) {
|
||||
process.exit(1);
|
||||
}
|
||||
SparoStartupBanner.logBanner({
|
||||
callerPackageJson: launchOptions.callerPackageJson
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'reflect-metadata';
|
||||
import { getFromContainer } from '../di/container';
|
||||
import { GitService } from '../services/GitService';
|
||||
import { TerminalService } from '../services/TerminalService';
|
||||
|
||||
/**
|
||||
* This class provides the useful function to check git version.
|
||||
|
@ -10,13 +11,17 @@ export class GitVersionCompatibility {
|
|||
|
||||
private constructor() {}
|
||||
|
||||
public static ensureGitVersion(): void {
|
||||
public static reportGitRequiredVersion(): boolean {
|
||||
const [major, minor, patch] = GitVersionCompatibility.getGitVersion();
|
||||
if (major < 2 || minor < 32) {
|
||||
throw new Error(
|
||||
`git version is too low. The minimal git version is >=2.32.0. Your git version is ${major}.${minor}.${patch}. Please upgrade git.`
|
||||
if (major < 2 || minor < 44) {
|
||||
const terminalService: TerminalService = getFromContainer(TerminalService);
|
||||
terminalService.terminal.writeErrorLine(
|
||||
`It appears your Git version(${major}.${minor}.${patch}) is too old. The minimal supported version is >=2.44.0.\nPlease upgrade to the latest Git version. Many Git optimizations are relatively new and not available in older versions of the software.`
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static getGitVersion(): [number, number, number] {
|
||||
|
|
Loading…
Reference in a new issue