vmware-archive / clarity

Clarity is a scalable, accessible, customizable, open source design system built with web components. Works with any JavaScript framework, built for enterprises, and designed to be inclusive.
http://clarity.design
MIT License
6.43k stars 760 forks source link

pre-commit hook adds unstaged files to the staging zone and then to commit itself #4679

Closed amalitsky closed 4 years ago

amalitsky commented 4 years ago

Describe the bug

Files from Untracked and Changes not staged for commit zone are pulled into the staging (and subsequently into commit) by npm run license:fix script run by pre-commit githook.

How to reproduce

  1. have three changed files in your tree: one in staged zone (Changes to be committed), one in Changes not staged for commit and another one in Untracked files:

    
    user@mac:clarity$ git status
    On branch func-return-value
    Changes to be committed:
    (use "git reset HEAD <file>..." to unstage)
    
    modified:   packages/core/src/modal/modal.element.ts

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)

modified:   packages/core/src/alert/alert-actions.element.ts

Untracked files: (use "git add ..." to include in what will be committed)

.gitmessage.txt
2. run `npm run license:fix` (which is run by husky pre-commit hook)
3. run `git status` once again:

user@mac:clarity$ git status On branch func-return-value Changes to be committed: (use "git reset HEAD ..." to unstage)

new file:   .gitmessage.txt
modified:   packages/core/src/alert/alert-actions.element.ts
modified:   packages/core/src/modal/modal.element.ts

Both un-staged files got moved into the _staged_ (_Changes to be committed_) zone and would have been included into resulting commit had I run `git commit` instead of `npm run license:fix`.

## Expected behavior
Unstaged files are ignored by git hook scripts (linters, checkers, etc) and aren't pulled into the commit automatically.

## Versions
- Type: MacBook
- OS: iOS
- git: 2.21.1

## Additional notes
Not sure whether this is bug or a feature but wanted to check before looking into ways of fixing it.

Thanks
coryrylan commented 4 years ago

Yes, this is a bug in the build that has not been addressed yet.

hippee-lee commented 4 years ago

Looks like the issue is with this line of the script: https://github.com/vmware/clarity/blob/master/scripts/update-license.js#L34

github-actions[bot] commented 4 years ago

Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.