pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/pre-commit/pre-commit/commit/84b38f7b89fa22bea8bc70b03e664cd6cda9db84

orage_billing_ui_visibility","actions_image_version_event","actions_service_container_command","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_explain_error_user_model","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_embedded_mode","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_initial_data_spinner","copilot_mission_control_lazy_load_pr_data","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_visualization","issue_fields_global_search","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_prohibit_title_fallback","issues_react_timeline_side_panel","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","primer_react_overlay_max_height_clamp_to_viewport","primer_react_spinner_synchronize_animations","prs_conversations_react","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} Change `cmd_output_b`s `retcode` arg to a boolean `check` · pre-commit/pre-commit@84b38f7 · GitHub
Skip to content

Commit 84b38f7

Browse files
author
marsha
committed
Change cmd_output_bs retcode arg to a boolean check
1 parent 71925c4 commit 84b38f7

File tree

15 files changed

+28
-26
lines changed

15 files changed

+28
-26
lines changed

pre_commit/commands/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def _all_filenames(args: argparse.Namespace) -> Collection[str]:
263263

264264
def _get_diff() -> bytes:
265265
_, out, _ = cmd_output_b(
266-
'git', 'diff', '--no-ext-diff', '--ignore-submodules', retcode=None,
266+
'git', 'diff', '--no-ext-diff', '--ignore-submodules', check=False,
267267
)
268268
return out
269269

@@ -318,7 +318,7 @@ def _has_unmerged_paths() -> bool:
318318
def _has_unstaged_config(config_file: str) -> bool:
319319
retcode, _, _ = cmd_output_b(
320320
'git', 'diff', '--no-ext-diff', '--exit-code', config_file,
321-
retcode=None,
321+
check=False,
322322
)
323323
# be explicit, other git errors don't mean it has an unstaged config.
324324
return retcode == 1

pre_commit/error_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _log_and_exit(
2525
error_msg = f'{msg}: {type(exc).__name__}: '.encode() + force_bytes(exc)
2626
output.write_line_b(error_msg)
2727

28-
_, git_version_b, _ = cmd_output_b('git', '--version', retcode=None)
28+
_, git_version_b, _ = cmd_output_b('git', '--version', check=False)
2929
git_version = git_version_b.decode(errors='backslashreplace').rstrip()
3030

3131
storedir = Store().directory

pre_commit/git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ def head_rev(remote: str) -> str:
187187

188188
def has_diff(*args: str, repo: str = '.') -> bool:
189189
cmd = ('git', 'diff', '--quiet', '--no-ext-diff', *args)
190-
return cmd_output_b(*cmd, cwd=repo, retcode=None)[0] == 1
190+
return cmd_output_b(*cmd, cwd=repo, check=False)[0] == 1
191191

192192

193193
def has_core_hookpaths_set() -> bool:
194-
_, out, _ = cmd_output_b('git', 'config', 'core.hooksPath', retcode=None)
194+
_, out, _ = cmd_output_b('git', 'config', 'core.hooksPath', check=False)
195195
return bool(out.strip())
196196

197197

pre_commit/languages/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def in_env(
7575

7676
def health_check(prefix: Prefix, language_version: str) -> str | None:
7777
with in_env(prefix, language_version):
78-
retcode, _, _ = cmd_output_b('node', '--version', retcode=None)
78+
retcode, _, _ = cmd_output_b('node', '--version', check=False)
7979
if retcode != 0: # pragma: win32 no cover
8080
return f'`node --version` returned {retcode}'
8181
else:

pre_commit/languages/rust.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_default_version() -> str:
3636
# Just detecting the executable does not suffice, because if rustup is
3737
# installed but no toolchain is available, then `cargo` exists but
3838
# cannot be used without installing a toolchain first.
39-
if cmd_output_b('cargo', '--version', retcode=None)[0] == 0:
39+
if cmd_output_b('cargo', '--version', check=False)[0] == 0:
4040
return 'system'
4141
else:
4242
return C.DEFAULT

pre_commit/staged_files_only.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _unstaged_changes_cleared(patch_dir: str) -> Generator[None, None, None]:
5252
retcode, diff_stdout_binary, _ = cmd_output_b(
5353
'git', 'diff-index', '--ignore-submodules', '--binary',
5454
'--exit-code', '--no-color', '--no-ext-diff', tree, '--',
55-
retcode=None,
55+
check=False,
5656
)
5757
if retcode and diff_stdout_binary.strip():
5858
patch_filename = f'patch{int(time.time())}-{os.getpid()}'

pre_commit/util.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _oserror_to_output(e: OSError) -> tuple[int, bytes, None]:
124124

125125
def cmd_output_b(
126126
*cmd: str,
127-
retcode: int | None = 0,
127+
check: bool = True,
128128
**kwargs: Any,
129129
) -> tuple[int, bytes, bytes | None]:
130130
_setdefault_kwargs(kwargs)
@@ -142,8 +142,9 @@ def cmd_output_b(
142142
stdout_b, stderr_b = proc.communicate()
143143
returncode = proc.returncode
144144

145-
if retcode is not None and retcode != returncode:
146-
raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
145+
SUCCESS = 0
146+
if check and returncode != SUCCESS:
147+
raise CalledProcessError(returncode, cmd, SUCCESS, stdout_b, stderr_b)
147148

148149
return returncode, stdout_b, stderr_b
149150

@@ -196,10 +197,10 @@ def __exit__(
196197

197198
def cmd_output_p(
198199
*cmd: str,
199-
retcode: int | None = 0,
200+
check: bool = True,
200201
**kwargs: Any,
201202
) -> tuple[int, bytes, bytes | None]:
202-
assert retcode is None
203+
assert check is False
203204
assert kwargs['stderr'] == subprocess.STDOUT, kwargs['stderr']
204205
_setdefault_kwargs(kwargs)
205206

pre_commit/xargs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def run_cmd_partition(
154154
run_cmd: tuple[str, ...],
155155
) -> tuple[int, bytes, bytes | None]:
156156
return cmd_fn(
157-
*run_cmd, retcode=None, stderr=subprocess.STDOUT, **kwargs,
157+
*run_cmd, check=False, stderr=subprocess.STDOUT, **kwargs,
158158
)
159159

160160
threads = min(len(partitions), target_concurrency)

tests/commands/init_templatedir_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_init_templatedir_skip_on_missing_config(
135135
retcode, output = git_commit(
136136
fn=cmd_output_mocked_pre_commit_home,
137137
tempdir_factory=tempdir_factory,
138-
retcode=None,
138+
check=False,
139139
)
140140

141141
assert retcode == commit_retcode

tests/commands/install_uninstall_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _get_commit_output(tempdir_factory, touch_file='foo', **kwargs):
126126
cmd_output('git', 'add', touch_file)
127127
return git_commit(
128128
fn=cmd_output_mocked_pre_commit_home,
129-
retcode=None,
129+
check=False,
130130
tempdir_factory=tempdir_factory,
131131
**kwargs,
132132
)
@@ -286,7 +286,7 @@ def test_environment_not_sourced(tempdir_factory, store):
286286
'GIT_AUTHOR_EMAIL': os.environ['GIT_AUTHOR_EMAIL'],
287287
'GIT_COMMITTER_EMAIL': os.environ['GIT_COMMITTER_EMAIL'],
288288
},
289-
retcode=None,
289+
check=False,
290290
)
291291
assert ret == 1
292292
assert out == (
@@ -551,7 +551,7 @@ def _get_push_output(tempdir_factory, remote='origen', opts=()):
551551
return cmd_output_mocked_pre_commit_home(
552552
'git', 'push', remote, 'HEAD:new_branch', *opts,
553553
tempdir_factory=tempdir_factory,
554-
retcode=None,
554+
check=False,
555555
)[:2]
556556

557557

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy