danger / danger-js

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

[BUG] all changes regardless of type are grouped incorrectly into `modified_files` in `danger.git` #1446

Closed xphir closed 1 month ago

xphir commented 2 months ago

Describe the bug

Since version 12.0.1, all changes (including deletions, creations, and modifications) are incorrectly grouped under modified_files. The created_files and deleted_files arrays remain empty, even when there are clearly file creations or deletions.

To Reproduce Steps to reproduce the behavior:

  1. On version 11.3.1, create a dangerfile.ts as follows:
    
    import { danger} from "danger"

console.log("Created", danger.git.created_files) console.log("Deleted", danger.git.deleted_files) console.log("Modified", danger.git.modified_files)

2. Run the command `npx danger pr https://github.com/danger/danger-js/pull/9`.
3. Observe the expected output:

Starting Danger PR on danger/danger-js#9 Created [ 'yarn.lock' ] Deleted [ 'npm-shrinkwrap.json' ] Modified [ 'README.md', 'package.json' ]

Danger: ✓ passed review, received no feedback.

4. Update the version to `12.0.1`
5. Run the same command: `npx danger pr https://github.com/danger/danger-js/pull/9`
6. Notice the unexpected and incorrect output:

Starting Danger PR on danger/danger-js#9 Created [] Deleted [] Modified [ 'README.md', 'npm-shrinkwrap.json', 'package.json', 'yarn.lock' ]

Danger: ✓ passed review, received no feedback.



**Expected behavior**
I would expect the behavior to remain consistent with version `11.3.1`, where deletions are grouped in `deleted_files`, creations in `created_files`, etc.

**Your Environment**
<!--- Include as many relevant details about the environment you experienced the bug in -->

 | software         | version
| ---------------- | -------
| danger.js          | `12.0.1`, `12.1.0` & `12.2.0`
| node             | `v20.12.1` & `v18.20.2`
| npm              | `10.5.0`
| Operating System | `MacOS Sonoma 14.4.1`
orta commented 1 month ago

Yeah, I could believe that https://github.com/danger/danger-js/pull/1440 triggers this