Skip to content

Commit

Permalink
↪️ Merge pull request #214 from lirantal/patch-1
Browse files Browse the repository at this point in the history
Use a unique exit code to identify baseline changes
  • Loading branch information
KevinHock authored Aug 4, 2019
2 parents 372e3b9 + d1c329b commit 2630cb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit 2630cb5

Please sign in to comment.