import { Shell , ShellResult } from '../../shell' ; import { Errorable } from '../../errorable' ; export class Git { constructor ( private readonly shell ) { } private async git ( args ) { const cmd = `git ${ args }` ; const sr = await this . shell . execCore ( cmd , this . shell . execOpts ( ) ) ; return sr ; } public async whenCreated ( commitId ) { const sr = await this . git ( `log --pretty=%ar -n 1 ${ commitId }` ) ; if ( sr . code === 0 ) { return sr . stdout ; } return null ; } public async checkout ( commitId ) { const sr = await this . git ( `checkout ${ commitId }` ) ; if ( sr . code === 0 ) { return { succeeded : true , result : null } ; } return { succeeded : false , error : [ sr . stderr ] } ; } }