Skip to content

Commit

Permalink
Merge branch 'main' into expose-generic-overload
Browse files Browse the repository at this point in the history
  • Loading branch information
niik authored Nov 20, 2024
2 parents 3edd62e + 86f78cd commit e9daa29
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions test/fast/git-process-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '../helpers'

import { gitVersion } from '../helpers'
import { pathToFileURL } from 'url'
import { track } from 'temp'
import assert from 'assert'
import { describe, it } from 'node:test'
Expand All @@ -21,22 +20,16 @@ const temp = track()

describe('git-process', () => {
it('can cancel in-progress git command', async () => {
const sourceRepoPath = temp.mkdirSync('desktop-git-clone-source')
const destinationRepoPath = temp.mkdirSync('desktop-git-clone-destination')

await git(['init'], sourceRepoPath)
await git(['commit', '--allow-empty', '-m', 'Init'], sourceRepoPath)

// git-hash-object will wait until stdin is closed so we can use this as
// an never-ending process to test the cancellation
const ac = new AbortController()
const task = git(
['clone', '--', pathToFileURL(sourceRepoPath).toString(), '.'],
destinationRepoPath,
{ signal: ac.signal }
)

ac.abort()
const result = await git(['hash-object', '--stdin'], process.cwd(), {
signal: ac.signal,
processCallback(process) {
process.on('spawn', () => ac.abort())
},
}).catch(e => e)

const result = await task.catch(e => e)
assert.ok(result instanceof ExecError)
assert.equal(result.code, 'ABORT_ERR')
})
Expand Down

0 comments on commit e9daa29

Please sign in to comment.