danger / danger-js

⚠️ Stop saying "you forgot to …" in code review
http://danger.systems/js/
MIT License
5.28k stars 368 forks source link

[BUG] : GitDSL not working correclty on created files #1143

Open pranshuchittora opened 3 years ago

pranshuchittora commented 3 years ago

Describe the bug GitDSL is not emitting all files that are created.

To Reproduce Steps to reproduce the behavior:

  1. Create a file
  2. Check for it in the GitDSL

Expected behavior

It should show src/App/App.js in the created files

Screenshots

~/github/react-app-danger-mvp-test on master ?20
❯ tree ./src
./src
├── App
│   └── App.js
├── entryBrowser.js
├── index.html
├── offline
│   └── offline.html
└── serviceWorker.js

2 directories, 5 files
~/github/react-app-danger-mvp-test on master ?20
❯ git add ./src/App
~/github/react-app-danger-mvp-test on master +1 ?23
❯ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
    new file:   src/App/App.js

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    .babelrc.js
    .changeset/
    .eslintignore
    .eslintrc.js
    .github/
    .gitignore
    .huskyrc.js
    .lintstagedrc.js
    .npmrc
    .prettierignore
    .prettierrc.js
    .stylelintignore
    .stylelintrc.js
    README.md
    dangerfile.js
    package.json
    src/entryBrowser.js
    src/index.html
    src/offline/
    src/serviceWorker.js
    webpack.config.js
    yarn.lock

~/github/react-app-danger-mvp-test on master +1 ?23                                                                  took 10s
❯ DANGER_TEST_PR='1' npx danger ci
Modified [ '.gitignore', 'dangerfile.js', 'package.json', 'yarn.lock' ]

Created [
  '.babelrc.js',
  '.changeset/config.json',
  '.eslintignore',
  '.eslintrc.js',
  '.github/workflows/build.yml',
  '.github/workflows/cancel.yml',
  '.github/workflows/validate.yml',
  '.github/workflows/version.yml',
  '.huskyrc.js',
  '.lintstagedrc.js',
  '.npmrc',
  '.prettierignore',
  '.prettierrc.js',
  '.stylelintignore',
  '.stylelintrc.js',
  'README.md',
  'src/entryBrowser.js',
  'src/index.html',
  'src/offline/offline.html',
  'src/serviceWorker.js',
  'webpack.config.js'
]
Deleted [ 'index.js' ]
Found no issues or messages from Danger. Removing any existing messages on GitHub.
~/github/react-app-danger-mvp-test on master +1 ?23                                                                  took 10s
❯

Your Environment

software version
danger.js 10.6.4
node 14
npm
Operating System Mac

Additional context Add any other context about the problem here.

orta commented 3 years ago

Sure, it could be a bug, hard to tell without a repro and just those logs though

fbartho commented 2 years ago

@pranshuchittora looking at your terminal output, it looks like you're trying to run DangerJS against a "staged" file, not a "committed" file. Is that correct?

DangerJS/GitDSL is intended to work against committed content. It's not really intended as a pre-commit hook. So that would explain the behavior you see.

(@ anyone -- please correct me if I'm wrong!)