11'use strict' ;
2- import { Iterables , Objects , Strings , TernarySearchTree } from './system' ;
2+ import { Iterables , Objects , Strings , TernarySearchTree , Versions } from './system' ;
33import { ConfigurationChangeEvent , Disposable , Event , EventEmitter , Range , TextEditor , Uri , window , WindowState , workspace , WorkspaceFolder , WorkspaceFoldersChangeEvent } from 'vscode' ;
44import { configuration , IRemotesConfig } from './configuration' ;
55import { CommandContext , DocumentSchemes , setCommandContext } from './constants' ;
@@ -1506,6 +1506,9 @@ export class GitService extends Disposable {
15061506 Logger . log ( `stashSave('${ repoPath } ', '${ message } ', ${ uris } )` ) ;
15071507
15081508 if ( uris === undefined ) return Git . stash_save ( repoPath , message ) ;
1509+
1510+ GitService . ensureGitVersion ( '2.13.2' , 'Stashing individual files' ) ;
1511+
15091512 const pathspecs = uris . map ( u => Git . splitPath ( u . fsPath , repoPath ) [ 0 ] ) ;
15101513 return Git . stash_push ( repoPath , pathspecs , message ) ;
15111514 }
@@ -1560,8 +1563,14 @@ export class GitService extends Disposable {
15601563 : sha ;
15611564 }
15621565
1563- static validateGitVersion ( major : number , minor : number ) : boolean {
1564- const [ gitMajor , gitMinor ] = this . getGitVersion ( ) . split ( '.' ) ;
1565- return ( parseInt ( gitMajor , 10 ) >= major && parseInt ( gitMinor , 10 ) >= minor ) ;
1566+ static compareGitVersion ( version : string , throwIfLessThan ?: Error ) {
1567+ return Versions . compare ( Versions . fromString ( this . getGitVersion ( ) ) , Versions . fromString ( version ) ) ;
1568+ }
1569+
1570+ static ensureGitVersion ( version : string , feature : string ) : void {
1571+ const gitVersion = this . getGitVersion ( ) ;
1572+ if ( Versions . compare ( Versions . fromString ( gitVersion ) , Versions . fromString ( version ) ) === - 1 ) {
1573+ throw new Error ( `${ feature } requires a newer version of Git (>= ${ version } ) than is currently installed (${ gitVersion } ). Please install a more recent version of Git to use this GitLens feature.` ) ;
1574+ }
15661575 }
1567- }
1576+ }
0 commit comments