Skip to content

Commit 2630cb5

Browse files
authored
↪️ Merge pull request #214 from lirantal/patch-1
Use a unique exit code to identify baseline changes
2 parents 372e3b9 + d1c329b commit 2630cb5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: detect_secrets/pre_commit_hook.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def main(argv=None):
8888
'Probably to keep line numbers of secrets up-to-date.\n'
8989
'Please `git add {}`, thank you.\n\n'.format(args.baseline[0]),
9090
)
91-
return 1
91+
return 3
9292

9393
return 0
9494

Diff for: tests/pre_commit_hook_test.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
def assert_commit_blocked(command):
1919
assert pre_commit_hook.main(command.split()) == 1
2020

21+
def assert_commit_blocked_with_diff_exit_code(command):
22+
assert pre_commit_hook.main(command.split()) == 3
2123

2224
def assert_commit_succeeds(command):
2325
assert pre_commit_hook.main(command.split()) == 0
@@ -154,7 +156,7 @@ def test_that_baseline_gets_updated(
154156
), mock.patch(
155157
'detect_secrets.pre_commit_hook.write_baseline_to_file',
156158
) as m:
157-
assert_commit_blocked(
159+
assert_commit_blocked_with_diff_exit_code(
158160
'--baseline will_be_mocked --use-all-plugins' +
159161
' test_data/files/file_with_secrets.py',
160162
)
@@ -210,7 +212,7 @@ def test_writes_new_baseline_if_modified(self):
210212
), mock.patch(
211213
'detect_secrets.pre_commit_hook.write_baseline_to_file',
212214
) as m:
213-
assert_commit_blocked(
215+
assert_commit_blocked_with_diff_exit_code(
214216
'--baseline will_be_mocked test_data/files/file_with_secrets.py',
215217
)
216218

0 commit comments

Comments
 (0)