Skip to content

Commit 619a9ab

Browse files
renovate[bot]jennifer-shehanecacieprins
authored
dependency: update dependency simple-git to v3.25.0 (#30076)
* empty commit * fix(deps): update dependency simple-git to v3.25.0 * cli entry * yarnlock * mock out simple-git for failing unit tests * fix yarn lock merge * changelog --------- Co-authored-by: Jennifer Shehane <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Cacie Prins <[email protected]>
1 parent f98810c commit 619a9ab

File tree

5 files changed

+199
-79
lines changed

5 files changed

+199
-79
lines changed

cli/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ _Released 10/1/2024 (PENDING)_
88
- Cypress now consumes [geckodriver](https://firefox-source-docs.mozilla.org/testing/geckodriver/index.html) to help automate the Firefox browser instead of [marionette-client](https://github.com/cypress-io/marionette-client). Addresses [#30217](https://github.com/cypress-io/cypress/issues/30217).
99
- Pass spec information to protocol's `beforeSpec` to improve troubleshooting when reporting on errors. Addressed in [#30316](https://github.com/cypress-io/cypress/pull/30316).
1010

11+
**Dependency Updates:**
12+
13+
- Updated `simple-git` from `3.16.0` to `3.25.0`. Addressed in [#30076](https://github.com/cypress-io/cypress/pull/30076).
14+
1115
## 13.15.0
1216

1317
_Released 9/25/2024_

packages/data-context/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"randomstring": "1.3.0",
5252
"react-docgen": "6.0.4",
5353
"semver": "7.3.2",
54-
"simple-git": "3.16.0",
54+
"simple-git": "3.25.0",
5555
"stringify-object": "^3.0.0",
5656
"underscore.string": "^3.3.6",
5757
"wonka": "^4.0.15"

packages/data-context/test/unit/sources/GitDataSource.spec.ts

-69
Original file line numberDiff line numberDiff line change
@@ -216,75 +216,6 @@ describe('GitDataSource', () => {
216216
expect(errorStub).to.be.callCount(1)
217217
})
218218

219-
context('Git hashes', () => {
220-
let clock: sinon.SinonFakeTimers
221-
222-
beforeEach(() => {
223-
clock = sinon.useFakeTimers()
224-
})
225-
226-
afterEach(() => {
227-
clock.restore()
228-
})
229-
230-
it('loads git hashes when first loaded', async () => {
231-
const dfd = pDefer()
232-
233-
gitInfo = new GitDataSource({
234-
isRunMode: false,
235-
projectRoot: projectPath,
236-
onBranchChange: sinon.stub(),
237-
onGitInfoChange: sinon.stub(),
238-
onError: sinon.stub(),
239-
onGitLogChange: dfd.resolve,
240-
})
241-
242-
await dfd.promise
243-
244-
expect(gitInfo.currentHashes).to.have.length(1)
245-
246-
expect(gitInfo.currentCommitInfo).to.exist
247-
expect(gitInfo.currentCommitInfo.message).to.eql('add all specs')
248-
expect(gitInfo.currentCommitInfo.hash).to.exist
249-
})
250-
251-
it('detects change in hashes after a commit', async () => {
252-
const dfd = pDefer()
253-
const afterCommit = pDefer()
254-
255-
const logCallback = sinon.stub()
256-
257-
logCallback.onFirstCall().callsFake(dfd.resolve)
258-
logCallback.onSecondCall().callsFake(afterCommit.resolve)
259-
260-
gitInfo = new GitDataSource({
261-
isRunMode: false,
262-
projectRoot: projectPath,
263-
onBranchChange: sinon.stub(),
264-
onGitInfoChange: sinon.stub(),
265-
onError: sinon.stub(),
266-
onGitLogChange: logCallback,
267-
})
268-
269-
await dfd.promise
270-
271-
expect(gitInfo.currentHashes).to.have.length(1)
272-
273-
const afterCommitSpec = toPosix(path.join(e2eFolder, 'afterCommit.cy.js'))
274-
275-
await fs.createFile(afterCommitSpec)
276-
277-
git.add(afterCommitSpec)
278-
git.commit('add afterCommit spec')
279-
280-
await clock.tickAsync(60010)
281-
282-
await afterCommit.promise
283-
284-
expect(gitInfo.currentHashes).to.have.length(2)
285-
})
286-
})
287-
288219
context('Git Hashes - no fake timers', () => {
289220
it('does not include commits that are part of the Git tree from a merge', async () => {
290221
const dfd = pDefer()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
import { expect, use } from 'chai'
2+
import sinonChai from 'sinon-chai'
3+
import sinon from 'sinon'
4+
import proxyquire from 'proxyquire'
5+
import pDefer, { DeferredPromise } from 'p-defer'
6+
7+
import { SimpleGit } from 'simple-git'
8+
import type { GitDataSource, GitDataSourceConfig } from '../../../src/sources/GitDataSource'
9+
import Chokidar from 'chokidar'
10+
11+
use(sinonChai)
12+
13+
type P<F extends keyof SimpleGit> = Parameters<SimpleGit[F]>
14+
type R<F extends keyof SimpleGit> = ReturnType<SimpleGit[F]>
15+
16+
interface GitDataSourceConstructor {
17+
new (config: GitDataSourceConfig): GitDataSource
18+
}
19+
20+
type GDSImport = {
21+
GitDataSource: GitDataSourceConstructor
22+
}
23+
24+
describe('GitDataSource', () => {
25+
let stubbedSimpleGit: {
26+
// Parameters<> only gets the last overload defined, which is
27+
// supposed to be the most permissive. However, SimpleGit defines
28+
// overloads in the opposite order, and we need the one that takes
29+
// a string.
30+
revparse: sinon.SinonStub<[option: string], R<'revparse'>>
31+
branch: sinon.SinonStub<P<'branch'>, R<'branch'>>
32+
status: sinon.SinonStub<P<'status'>, R<'status'>>
33+
log: sinon.SinonStub<P<'log'>, R<'log'>>
34+
}
35+
let stubbedWatchInstance: sinon.SinonStubbedInstance<Chokidar.FSWatcher>
36+
37+
let gitDataSourceImport: GDSImport
38+
let fakeTimers: sinon.SinonFakeTimers
39+
40+
beforeEach(() => {
41+
fakeTimers = sinon.useFakeTimers()
42+
stubbedSimpleGit = {
43+
revparse: sinon.stub<[option: string], R<'revparse'>>(),
44+
branch: sinon.stub<P<'branch'>, R<'branch'>>(),
45+
status: sinon.stub<P<'status'>, R<'status'>>(),
46+
log: sinon.stub<P<'log'>, R<'log'>>(),
47+
}
48+
49+
stubbedWatchInstance = sinon.createStubInstance(Chokidar.FSWatcher)
50+
sinon.stub(Chokidar, 'watch').returns(stubbedWatchInstance)
51+
52+
gitDataSourceImport = proxyquire.noCallThru()('../../../src/sources/GitDataSource', {
53+
'simple-git' () {
54+
return stubbedSimpleGit
55+
},
56+
})
57+
})
58+
59+
afterEach(() => {
60+
sinon.restore()
61+
fakeTimers.restore()
62+
})
63+
64+
describe('Unit', () => {
65+
describe('in open mode', () => {
66+
let gds: GitDataSource
67+
let projectRoot: string
68+
let branchName: string
69+
let onBranchChange: sinon.SinonStub<[branch: string | null], void>
70+
let onGitInfoChange: sinon.SinonStub<[specPath: string[]], void>
71+
let onError: sinon.SinonStub<[err: any], void>
72+
let onGitLogChange: sinon.SinonStub<[shas: string[]], void>
73+
const firstHashes = [
74+
{ hash: 'abc' },
75+
]
76+
const firstHashesReturnValue = ['abc']
77+
const secondHashes = [...firstHashes, { hash: 'efg' }]
78+
const secondHashesReturnValue = [...firstHashesReturnValue, 'efg']
79+
let firstGitLogCall: DeferredPromise<void>
80+
let secondGitLogCall: DeferredPromise<void>
81+
82+
beforeEach(async () => {
83+
firstGitLogCall = pDefer()
84+
secondGitLogCall = pDefer()
85+
branchName = 'main'
86+
onBranchChange = sinon.stub()
87+
onGitInfoChange = sinon.stub()
88+
onError = sinon.stub()
89+
onGitLogChange = sinon.stub()
90+
91+
projectRoot = '/root'
92+
93+
// @ts-ignore
94+
stubbedSimpleGit.log.onFirstCall()
95+
// @ts-expect-error
96+
.callsFake(() => {
97+
firstGitLogCall.resolve()
98+
99+
return { all: firstHashes }
100+
})
101+
.onSecondCall()
102+
// @ts-expect-error
103+
.callsFake(() => {
104+
secondGitLogCall.resolve()
105+
106+
return { all: secondHashes }
107+
})
108+
109+
// #verifyGitRepo
110+
111+
// constructor verifies the repo in open mode via #refreshAllGitData, but does not wait for it :womp:
112+
const revparseP = pDefer<void>()
113+
114+
// SimpleGit returns a chainable, but we only care about the promise
115+
// @ts-expect-error
116+
stubbedSimpleGit.revparse.callsFake(() => {
117+
revparseP.resolve()
118+
119+
return Promise.resolve(projectRoot)
120+
})
121+
122+
// wait for revparse to be called, so we can be assured that GitDataSource has initialized
123+
// up to this point
124+
125+
// #loadAndWatchCurrentBranch
126+
127+
// next in initialization, it loads the current branch
128+
const branchP = pDefer<void>()
129+
130+
// again, ignoring type warning re: chaining
131+
// @ts-expect-error
132+
stubbedSimpleGit.branch.callsFake(() => {
133+
branchP.resolve()
134+
135+
return Promise.resolve({ current: branchName })
136+
})
137+
138+
const onBranchChangeP = pDefer<void>()
139+
140+
onBranchChange.callsFake(() => onBranchChangeP.resolve())
141+
142+
gds = new gitDataSourceImport.GitDataSource({
143+
isRunMode: false,
144+
projectRoot,
145+
onBranchChange,
146+
onGitInfoChange,
147+
onError,
148+
onGitLogChange,
149+
})
150+
151+
await revparseP.promise
152+
await branchP.promise
153+
await onBranchChangeP.promise
154+
expect(onBranchChange).to.be.calledWith(branchName)
155+
})
156+
157+
describe('.get currentHashes', () => {
158+
describe('after first load', () => {
159+
beforeEach(async () => {
160+
await firstGitLogCall.promise
161+
})
162+
163+
it('returns the current hashes', () => {
164+
expect(gds.currentHashes).to.have.same.members(firstHashesReturnValue)
165+
})
166+
})
167+
168+
describe('after sixty seconds, when there are additional hashes', () => {
169+
it('returns the current hashes', async () => {
170+
await fakeTimers.tickAsync(60001)
171+
await secondGitLogCall.promise
172+
expect(gds.currentHashes).to.have.same.members(secondHashesReturnValue)
173+
})
174+
})
175+
})
176+
})
177+
})
178+
})

yarn.lock

+16-9
Original file line numberDiff line numberDiff line change
@@ -13306,10 +13306,10 @@ [email protected]:
1330613306
dependencies:
1330713307
ms "^2.1.1"
1330813308

13309-
debug@4, debug@4.3.4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@~4.3.1:
13310-
version "4.3.4"
13311-
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
13312-
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
13309+
debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@^4.3.5, debug@~4.3.1:
13310+
version "4.3.6"
13311+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b"
13312+
integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==
1331313313
dependencies:
1331413314
ms "2.1.2"
1331513315

@@ -13334,6 +13334,13 @@ [email protected]:
1333413334
dependencies:
1333513335
ms "2.1.2"
1333613336

13337+
13338+
version "4.3.4"
13339+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
13340+
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
13341+
dependencies:
13342+
ms "2.1.2"
13343+
1333713344
debug@^3.1.0, debug@^3.2.6, debug@^3.2.7:
1333813345
version "3.2.7"
1333913346
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
@@ -27929,14 +27936,14 @@ simple-get@^4.0.0:
2792927936
once "^1.3.1"
2793027937
simple-concat "^1.0.0"
2793127938

27932-
simple-git@3.16.0:
27933-
version "3.16.0"
27934-
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.16.0.tgz#421773e24680f5716999cc4a1d60127b4b6a9dec"
27935-
integrity sha512-zuWYsOLEhbJRWVxpjdiXl6eyAyGo/KzVW+KFhhw9MqEEJttcq+32jTWSGyxTdf9e/YCohxRE+9xpWFj9FdiJNw==
27939+
simple-git@3.25.0:
27940+
version "3.25.0"
27941+
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.25.0.tgz#3666e76d6831f0583dc380645945b97e0ac4aab6"
27942+
integrity sha512-KIY5sBnzc4yEcJXW7Tdv4viEz8KyG+nU0hay+DWZasvdFOYKeUZ6Xc25LUHHjw0tinPT7O1eY6pzX7pRT1K8rw==
2793627943
dependencies:
2793727944
"@kwsites/file-exists" "^1.1.1"
2793827945
"@kwsites/promise-deferred" "^1.1.1"
27939-
debug "^4.3.4"
27946+
debug "^4.3.5"
2794027947

2794127948
simple-swizzle@^0.2.2:
2794227949
version "0.2.2"

0 commit comments

Comments
 (0)