MCPcopy
hub / github.com/desktop/desktop / revertCommit

Function revertCommit

app/src/lib/git/revert.ts:22–55  ·  view source on GitHub ↗
(
  repository: Repository,
  commit: Commit,
  currentRemote: IRemote | null,
  progressCallback?: (progress: IRevertProgress) => void
)

Source from the content-addressed store, hash-verified

20 * @param commit - The SHA of the commit to be reverted
21 */
22export 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}

Callers 2

revert-test.tsFile · 0.90
revertCommitMethod · 0.90

Calls 5

envForRemoteOperationFunction · 0.90
gitFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected