import { inject , injectable } from 'inversify' ; import { IApplicationShell } from '../../application/types' ; import { CommitDetails } from '../../common/types' ; import { IServiceContainer } from '../../ioc/types' ; import { IGitServiceFactory } from '../../types' ; import { ICommitViewerFactory } from '../../viewers/types' ; import { command } from '../registration' ; import { IGitCheckoutCommandHandler } from '../types' ; @ injectable ( ) export class GitCheckoutCommandHandler implements IGitCheckoutCommandHandler { constructor ( @ inject ( IServiceContainer ) private serviceContainer , @ inject ( ICommitViewerFactory ) private commitViewerFactory , @ inject ( IApplicationShell ) private applicationShell ) { } @ command ( 'git.commit.checkout' , IGitCheckoutCommandHandler ) public async checkoutCommit ( commit ) { commit = commit ? commit : this . commitViewerFactory . getCommitViewer ( ) . selectedCommit ; const gitService = await this . serviceContainer . get < IGitServiceFactory > ( IGitServiceFactory ) . createGitService ( commit . workspaceFolder ) ; gitService . checkout ( commit . logEntry . hash . full ) . catch ( err => { if ( typeof err === 'string' ) { this . applicationShell . showErrorMessage ( err ) ; } } ) ; } }