Together-Java / TJ-Bot

TJ-Bot is a Discord Bot used on the Together Java server. It is maintained by the community, anyone can contribute.
https://togetherjava.org
GNU General Public License v3.0
101 stars 87 forks source link

Pre-commit hook includes untracked files in commits #1039

Closed christolis closed 6 months ago

christolis commented 7 months ago

Describe the bug From the looks of it, whenever one attempts to commit any changes while having untracked files in their working tree, the pre-commit hook also includes these files in the commit. This is somewhat severe because I accidentally shared some untracked configuration files that included a Discord bot token for my testing bot, which was thankfully revoked by Discord itself as soon as I pushed.

Expected behavior The pre-commit hooks should not include untracked files.

To Reproduce

  1. Make a new file in the working directory that is not tracked by .gitignore.
  2. Ensure that the file is untracked by using git restore --staged <file_name>.
  3. Change a different file's contents, such as a Java source code file that is tracked.
  4. Add the Java source code file to the index and make a commit from it.
  5. Assuming the pre-commit hook was executed with your commit, you should now see the untracked file included in the commit.

Screenshots

image image image

Additional context macOS version: Sonoma 14.3.1 (23D60) git version: 2.39.3 (Apple Git-145)