Skip to content

Commit

Permalink
dependency: update dependency simple-git to v3.25.0 (#30076)
Browse files Browse the repository at this point in the history
* 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 <jennifer@cypress.io>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Cacie Prins <cacie@cypress.io>
  • Loading branch information
3 people authored Oct 2, 2024
1 parent f98810c commit 619a9ab
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 79 deletions.
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ _Released 10/1/2024 (PENDING)_
- 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).
- 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).

**Dependency Updates:**

- Updated `simple-git` from `3.16.0` to `3.25.0`. Addressed in [#30076](https://github.com/cypress-io/cypress/pull/30076).

## 13.15.0

_Released 9/25/2024_
Expand Down
2 changes: 1 addition & 1 deletion packages/data-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"randomstring": "1.3.0",
"react-docgen": "6.0.4",
"semver": "7.3.2",
"simple-git": "3.16.0",
"simple-git": "3.25.0",
"stringify-object": "^3.0.0",
"underscore.string": "^3.3.6",
"wonka": "^4.0.15"
Expand Down
69 changes: 0 additions & 69 deletions packages/data-context/test/unit/sources/GitDataSource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,75 +216,6 @@ describe('GitDataSource', () => {
expect(errorStub).to.be.callCount(1)
})

context('Git hashes', () => {
let clock: sinon.SinonFakeTimers

beforeEach(() => {
clock = sinon.useFakeTimers()
})

afterEach(() => {
clock.restore()
})

it('loads git hashes when first loaded', async () => {
const dfd = pDefer()

gitInfo = new GitDataSource({
isRunMode: false,
projectRoot: projectPath,
onBranchChange: sinon.stub(),
onGitInfoChange: sinon.stub(),
onError: sinon.stub(),
onGitLogChange: dfd.resolve,
})

await dfd.promise

expect(gitInfo.currentHashes).to.have.length(1)

expect(gitInfo.currentCommitInfo).to.exist
expect(gitInfo.currentCommitInfo.message).to.eql('add all specs')
expect(gitInfo.currentCommitInfo.hash).to.exist
})

it('detects change in hashes after a commit', async () => {
const dfd = pDefer()
const afterCommit = pDefer()

const logCallback = sinon.stub()

logCallback.onFirstCall().callsFake(dfd.resolve)
logCallback.onSecondCall().callsFake(afterCommit.resolve)

gitInfo = new GitDataSource({
isRunMode: false,
projectRoot: projectPath,
onBranchChange: sinon.stub(),
onGitInfoChange: sinon.stub(),
onError: sinon.stub(),
onGitLogChange: logCallback,
})

await dfd.promise

expect(gitInfo.currentHashes).to.have.length(1)

const afterCommitSpec = toPosix(path.join(e2eFolder, 'afterCommit.cy.js'))

await fs.createFile(afterCommitSpec)

git.add(afterCommitSpec)
git.commit('add afterCommit spec')

await clock.tickAsync(60010)

await afterCommit.promise

expect(gitInfo.currentHashes).to.have.length(2)
})
})

context('Git Hashes - no fake timers', () => {
it('does not include commits that are part of the Git tree from a merge', async () => {
const dfd = pDefer()
Expand Down
178 changes: 178 additions & 0 deletions packages/data-context/test/unit/sources/GitDataSource_unit.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import { expect, use } from 'chai'
import sinonChai from 'sinon-chai'
import sinon from 'sinon'
import proxyquire from 'proxyquire'
import pDefer, { DeferredPromise } from 'p-defer'

import { SimpleGit } from 'simple-git'
import type { GitDataSource, GitDataSourceConfig } from '../../../src/sources/GitDataSource'
import Chokidar from 'chokidar'

use(sinonChai)

type P<F extends keyof SimpleGit> = Parameters<SimpleGit[F]>
type R<F extends keyof SimpleGit> = ReturnType<SimpleGit[F]>

interface GitDataSourceConstructor {
new (config: GitDataSourceConfig): GitDataSource
}

type GDSImport = {
GitDataSource: GitDataSourceConstructor
}

describe('GitDataSource', () => {
let stubbedSimpleGit: {
// Parameters<> only gets the last overload defined, which is
// supposed to be the most permissive. However, SimpleGit defines
// overloads in the opposite order, and we need the one that takes
// a string.
revparse: sinon.SinonStub<[option: string], R<'revparse'>>
branch: sinon.SinonStub<P<'branch'>, R<'branch'>>
status: sinon.SinonStub<P<'status'>, R<'status'>>
log: sinon.SinonStub<P<'log'>, R<'log'>>
}
let stubbedWatchInstance: sinon.SinonStubbedInstance<Chokidar.FSWatcher>

let gitDataSourceImport: GDSImport
let fakeTimers: sinon.SinonFakeTimers

beforeEach(() => {
fakeTimers = sinon.useFakeTimers()
stubbedSimpleGit = {
revparse: sinon.stub<[option: string], R<'revparse'>>(),
branch: sinon.stub<P<'branch'>, R<'branch'>>(),
status: sinon.stub<P<'status'>, R<'status'>>(),
log: sinon.stub<P<'log'>, R<'log'>>(),
}

stubbedWatchInstance = sinon.createStubInstance(Chokidar.FSWatcher)
sinon.stub(Chokidar, 'watch').returns(stubbedWatchInstance)

gitDataSourceImport = proxyquire.noCallThru()('../../../src/sources/GitDataSource', {
'simple-git' () {
return stubbedSimpleGit
},
})
})

afterEach(() => {
sinon.restore()
fakeTimers.restore()
})

describe('Unit', () => {
describe('in open mode', () => {
let gds: GitDataSource
let projectRoot: string
let branchName: string
let onBranchChange: sinon.SinonStub<[branch: string | null], void>
let onGitInfoChange: sinon.SinonStub<[specPath: string[]], void>
let onError: sinon.SinonStub<[err: any], void>
let onGitLogChange: sinon.SinonStub<[shas: string[]], void>
const firstHashes = [
{ hash: 'abc' },
]
const firstHashesReturnValue = ['abc']
const secondHashes = [...firstHashes, { hash: 'efg' }]
const secondHashesReturnValue = [...firstHashesReturnValue, 'efg']
let firstGitLogCall: DeferredPromise<void>
let secondGitLogCall: DeferredPromise<void>

beforeEach(async () => {
firstGitLogCall = pDefer()
secondGitLogCall = pDefer()
branchName = 'main'
onBranchChange = sinon.stub()
onGitInfoChange = sinon.stub()
onError = sinon.stub()
onGitLogChange = sinon.stub()

projectRoot = '/root'

// @ts-ignore
stubbedSimpleGit.log.onFirstCall()
// @ts-expect-error
.callsFake(() => {
firstGitLogCall.resolve()

return { all: firstHashes }
})
.onSecondCall()
// @ts-expect-error
.callsFake(() => {
secondGitLogCall.resolve()

return { all: secondHashes }
})

// #verifyGitRepo

// constructor verifies the repo in open mode via #refreshAllGitData, but does not wait for it :womp:
const revparseP = pDefer<void>()

// SimpleGit returns a chainable, but we only care about the promise
// @ts-expect-error
stubbedSimpleGit.revparse.callsFake(() => {
revparseP.resolve()

return Promise.resolve(projectRoot)
})

// wait for revparse to be called, so we can be assured that GitDataSource has initialized
// up to this point

// #loadAndWatchCurrentBranch

// next in initialization, it loads the current branch
const branchP = pDefer<void>()

// again, ignoring type warning re: chaining
// @ts-expect-error
stubbedSimpleGit.branch.callsFake(() => {
branchP.resolve()

return Promise.resolve({ current: branchName })
})

const onBranchChangeP = pDefer<void>()

onBranchChange.callsFake(() => onBranchChangeP.resolve())

gds = new gitDataSourceImport.GitDataSource({
isRunMode: false,
projectRoot,
onBranchChange,
onGitInfoChange,
onError,
onGitLogChange,
})

await revparseP.promise
await branchP.promise
await onBranchChangeP.promise
expect(onBranchChange).to.be.calledWith(branchName)
})

describe('.get currentHashes', () => {
describe('after first load', () => {
beforeEach(async () => {
await firstGitLogCall.promise
})

it('returns the current hashes', () => {
expect(gds.currentHashes).to.have.same.members(firstHashesReturnValue)
})
})

describe('after sixty seconds, when there are additional hashes', () => {
it('returns the current hashes', async () => {
await fakeTimers.tickAsync(60001)
await secondGitLogCall.promise
expect(gds.currentHashes).to.have.same.members(secondHashesReturnValue)
})
})
})
})
})
})
25 changes: 16 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13306,10 +13306,10 @@ debug@3.2.6:
dependencies:
ms "^2.1.1"

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:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
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:
version "4.3.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b"
integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==
dependencies:
ms "2.1.2"

Expand All @@ -13334,6 +13334,13 @@ debug@4.3.3:
dependencies:
ms "2.1.2"

debug@4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"

debug@^3.1.0, debug@^3.2.6, debug@^3.2.7:
version "3.2.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
Expand Down Expand Up @@ -27929,14 +27936,14 @@ simple-get@^4.0.0:
once "^1.3.1"
simple-concat "^1.0.0"

simple-git@3.16.0:
version "3.16.0"
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.16.0.tgz#421773e24680f5716999cc4a1d60127b4b6a9dec"
integrity sha512-zuWYsOLEhbJRWVxpjdiXl6eyAyGo/KzVW+KFhhw9MqEEJttcq+32jTWSGyxTdf9e/YCohxRE+9xpWFj9FdiJNw==
simple-git@3.25.0:
version "3.25.0"
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.25.0.tgz#3666e76d6831f0583dc380645945b97e0ac4aab6"
integrity sha512-KIY5sBnzc4yEcJXW7Tdv4viEz8KyG+nU0hay+DWZasvdFOYKeUZ6Xc25LUHHjw0tinPT7O1eY6pzX7pRT1K8rw==
dependencies:
"@kwsites/file-exists" "^1.1.1"
"@kwsites/promise-deferred" "^1.1.1"
debug "^4.3.4"
debug "^4.3.5"

simple-swizzle@^0.2.2:
version "0.2.2"
Expand Down

15 comments on commit 619a9ab

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/linux-arm64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/linux-x64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/linux-arm64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/linux-x64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-arm64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/linux-arm64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-arm64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-x64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-arm64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-x64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-x64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/linux-x64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/linux-arm64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-arm64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 619a9ab Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-x64/develop-619a9ab5118a30049a608502e3a4f1e64ae61f8e/cypress.tgz

Please sign in to comment.