From 8e8041ab1a2d1466e5e0dfcf28257bb776096c0e Mon Sep 17 00:00:00 2001 From: m3ndax Date: Thu, 7 Sep 2023 00:25:15 +0200 Subject: [PATCH] Improved Error Handling in `remap_file` Function and Added `.DS_Store` to `.gitignore (#3195) ### Description: This pull request introduces two significant changes: **Improved Error Handling in `remap_file` Function:** - The error handling in the `remap_file` function has been simplified for improved clarity and user-friendliness. The original code included a combination of `assert` and `exit`, which could be perplexing during runtime. **Changes Made:** - Replaced the original `assert` and `exit` with a more straightforward `if-else` block for handling errors. - Utilized `sys.exit` for clear error messages and proper program termination when an error occurs. **Why I Did It:** - Improved Clarity: The original code's `assert` primarily served debugging purposes and might not behave as expected during runtime. The new code offers clarity and predictability. - User-Friendly Errors: The updated code provides users with easily understandable error messages. **Added `.DS_Store` to `.gitignore`:** - `.DS_Store` files are commonly generated by macOS Finder to store folder-specific metadata. They do not need to be tracked in version control. **Changes Made:** - Added `.DS_Store` to the `.gitignore` file. **Why I Did It:** - To prevent `.DS_Store` files from being tracked in the Git repository, ensuring a cleaner repository and avoiding unintended commits of macOS-specific files. ### Improvements: - **Better Error Handling:** The new code in the `remap_file` function ensures the program exits gracefully with informative error messages when errors occur. - **Enhanced Code Clarity:** The code now communicates its intentions more clearly with `sys.exit` for handling expected runtime errors. - **Cleaner Git Repository:** The addition of `.DS_Store` to `.gitignore` prevents the tracking of macOS-specific files in version control. --- .gitignore | 3 +++ scripts/fix_cc_deps.py | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 410443942446..2ce3aadd0139 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ compile_commands.json # generated by utils/treesitter/helix.sh /.helix/ + +# Ignore .DS_Store files +.DS_Store diff --git a/scripts/fix_cc_deps.py b/scripts/fix_cc_deps.py index 99f925470e56..63d452d57e11 100755 --- a/scripts/fix_cc_deps.py +++ b/scripts/fix_cc_deps.py @@ -96,7 +96,6 @@ def remap_file(label: str) -> str: return path.replace(":", "/") assert repo in EXTERNAL_REPOS, repo return EXTERNAL_REPOS[repo].remap(path) - exit(f"Don't know how to remap label '{label}'") def get_bazel_list(list_child: ElementTree.Element, is_file: bool) -> Set[str]: