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

Use a unique exit code to identify baseline changes #214

Merged
merged 2 commits into from
Aug 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion detect_secrets/pre_commit_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def main(argv=None):
'Probably to keep line numbers of secrets up-to-date.\n'
'Please `git add {}`, thank you.\n\n'.format(args.baseline[0]),
)
return 1
return 3

return 0

Expand Down
6 changes: 4 additions & 2 deletions tests/pre_commit_hook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
def assert_commit_blocked(command):
assert pre_commit_hook.main(command.split()) == 1

def assert_commit_blocked_with_diff_exit_code(command):
assert pre_commit_hook.main(command.split()) == 3

def assert_commit_succeeds(command):
assert pre_commit_hook.main(command.split()) == 0
Expand Down Expand Up @@ -154,7 +156,7 @@ def test_that_baseline_gets_updated(
), mock.patch(
'detect_secrets.pre_commit_hook.write_baseline_to_file',
) as m:
assert_commit_blocked(
assert_commit_blocked_with_diff_exit_code(
'--baseline will_be_mocked --use-all-plugins' +
' test_data/files/file_with_secrets.py',
)
Expand Down Expand Up @@ -210,7 +212,7 @@ def test_writes_new_baseline_if_modified(self):
), mock.patch(
'detect_secrets.pre_commit_hook.write_baseline_to_file',
) as m:
assert_commit_blocked(
assert_commit_blocked_with_diff_exit_code(
'--baseline will_be_mocked test_data/files/file_with_secrets.py',
)

Expand Down