Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure pre-commit hook scans staged files #13

Merged
merged 1 commit into from
Mar 24, 2016

Conversation

mtdowling
Copy link
Contributor

This commit updates the pre-commit hook to scan staged files instead of files in the working directory.

This ensures that if a staged file was invalid, then the working directory version of the file was fixed, that the --scan command will still detect the error in the staged file rather than thinking the problem is fixed due to the modified working directory file. See here for the added test case.

In order to achieve this, I introduced the --cached option to scan. This matches the --cached option from git grep. I also added --no-index and --untracked. With the addition of these changes, I added more validation to the provided arguments of the tool to ensure that the user only supplies arguments related to the subcommand they are running, and that mutually exclusive arguments are not present. For example, --recursive cannot be used alongside --cached because --recursive is only relevant when working with files outside of the git repository.

Closes #12

@trevorrowe @jamesls @jeskew

@jeskew
Copy link

jeskew commented Mar 23, 2016

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pre-commit hook scans working directory instead of staging area?
2 participants