Skip to content

Commit

Permalink
fix: Files with special characters aren't handled properly in GitData…
Browse files Browse the repository at this point in the history
…Source on Windows (#21436)
  • Loading branch information
MuazOthman authored May 13, 2022
1 parent dcb4a61 commit a86514d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ windowsWorkflowFilters: &windows-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ '10.0-release', << pipeline.git.branch >> ]
- equal: [ ryanm/chore/fix-tests-in-10.0, << pipeline.git.branch >> ]
- equal: [ muaz/UNIFY-1741-fix-git-cmd-win, << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
value: << pipeline.git.branch >>
Expand Down
28 changes: 21 additions & 7 deletions packages/app/cypress/e2e/specs_list_actual_git_repo.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ describe('Spec List - Git Status', () => {
})

it('shows correct git status for files using real git repo', () => {
cy.wait(500)

// newly created, not yet committed
// this is performed by the task `initGitRepoForTestProject`
cy.get('[data-cy-row="foo.spec.js"] [data-cy="git-info-row"] svg')
Expand All @@ -34,6 +36,7 @@ describe('Spec List - Git Status', () => {
)
})

cy.wait(500)
// should update via GraphQL subscription, now the status is modified.
cy.get('[data-cy-row="dom-container.spec.js"] [data-cy="git-info-row"] svg')
.should('have.class', 'icon-light-orange-50')
Expand All @@ -46,24 +49,35 @@ describe('Spec List - Git Status', () => {
)
})

cy.wait(500)

// even if a created file is updated, the status should stay created
cy.get('[data-cy-row="foo.spec.js"] [data-cy="git-info-row"] svg')
.should('have.class', 'icon-light-jade-50')

cy.withCtx((ctx) => {
ctx.fs.writeFileSync(
ctx.path.join(ctx.currentProject!, 'cypress', 'e2e', 'dom-container.spec.js'),
if (Cypress.platform !== 'win32') {
// skip this test in Windows because of possible divergence in git behavior related to file permissions/stats
// TLDR: git config value `core.filemode` should be set to false
// See https://stackoverflow.com/questions/14564946/git-status-shows-changed-files-but-git-diff-doesnt and
// https://github.com/microsoft/WSL/issues/184 for reference

cy.withCtx((ctx) => {
ctx.fs.writeFileSync(
ctx.path.join(ctx.currentProject!, 'cypress', 'e2e', 'dom-container.spec.js'),
`describe('Dom Content', () => {
it('renders a container', () => {
cy.get('.container')
})
})
`,
'utf-8',
)
})
)
})

cy.get('[data-cy-row="dom-container.spec.js"] [data-cy="git-info-row"] svg')
.should('have.class', 'icon-light-gray-500')
cy.wait(500)

cy.get('[data-cy-row="dom-container.spec.js"] [data-cy="git-info-row"] svg')
.should('have.class', 'icon-light-gray-500')
}
})
})
2 changes: 1 addition & 1 deletion packages/data-context/src/sources/GitDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export class GitDataSource {
}

async #getInfoWindows (absolutePaths: readonly string[]) {
const paths = absolutePaths.map((x) => path.resolve(x)).join(',')
const paths = absolutePaths.map((x) => `"${path.resolve(x)}"`).join(',')
const cmd = `FOR %x in (${paths}) DO (${GIT_LOG_COMMAND} %x)`
const result = await execa(cmd, { shell: true, cwd: this.config.projectRoot })

Expand Down

1 comment on commit a86514d

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a86514d May 13, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.0/linux-x64/10.0-release-a86514d5f1554d4acbfbf7c2a22b927ab271139d/cypress.tgz

Please sign in to comment.