( repository: Repository, commit: Commit, currentRemote: IRemote | null, progressCallback?: (progress: IRevertProgress) => void )
| 20 | * @param commit - The SHA of the commit to be reverted |
| 21 | */ |
| 22 | export async function revertCommit( |
| 23 | repository: Repository, |
| 24 | commit: Commit, |
| 25 | currentRemote: IRemote | null, |
| 26 | progressCallback?: (progress: IRevertProgress) => void |
| 27 | ) { |
| 28 | const args = ['revert'] |
| 29 | if (commit.parentSHAs.length > 1) { |
| 30 | args.push('-m', '1') |
| 31 | } |
| 32 | |
| 33 | args.push(commit.sha) |
| 34 | |
| 35 | let opts: IGitStringExecutionOptions = {} |
| 36 | if (progressCallback) { |
| 37 | const env = await envForRemoteOperation( |
| 38 | getFallbackUrlForProxyResolve(repository, currentRemote) |
| 39 | ) |
| 40 | opts = await executionOptionsWithProgress( |
| 41 | { env, trackLFSProgress: true }, |
| 42 | new RevertProgressParser(), |
| 43 | progress => { |
| 44 | const description = |
| 45 | progress.kind === 'progress' ? progress.details.text : progress.text |
| 46 | const title = progress.kind === 'progress' ? progress.details.title : '' |
| 47 | const value = progress.percent |
| 48 | |
| 49 | progressCallback({ kind: 'revert', description, value, title }) |
| 50 | } |
| 51 | ) |
| 52 | } |
| 53 | |
| 54 | await git(args, repository.path, 'revert', opts) |
| 55 | } |
no test coverage detected