feat: increase the minimal supported git version

This commit is contained in:
Cheng Liu 2024-03-05 08:58:13 -08:00
parent 12ddfb4710
commit 379e5be367
No known key found for this signature in database
GPG key ID: EEC8452F7DB85CD6
3 changed files with 15 additions and 6 deletions

View file

@ -21,7 +21,9 @@ export class SparoCICommandLine {
telemetryService.setCollectTelemetryFunction(launchOptions.collectTelemetryAsync);
}
GitVersionCompatibility.ensureGitVersion();
if (GitVersionCompatibility.reportGitRequiredVersion()) {
process.exit(1);
}
SparoStartupBanner.logBanner({
callerPackageJson: launchOptions.callerPackageJson
});

View file

@ -22,7 +22,9 @@ export class SparoCommandLine {
telemetryService.setCollectTelemetryFunction(launchOptions.collectTelemetryAsync);
}
GitVersionCompatibility.ensureGitVersion();
if (GitVersionCompatibility.reportGitRequiredVersion()) {
process.exit(1);
}
SparoStartupBanner.logBanner({
callerPackageJson: launchOptions.callerPackageJson
});

View file

@ -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] {