Parcourir la source

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.
m3ndax il y a 2 ans
Parent
commit
8e8041ab1a
2 fichiers modifiés avec 3 ajouts et 1 suppressions
  1. 3 0
      .gitignore
  2. 0 1
      scripts/fix_cc_deps.py

+ 3 - 0
.gitignore

@@ -33,3 +33,6 @@ compile_commands.json
 
 # generated by utils/treesitter/helix.sh
 /.helix/
+
+# Ignore .DS_Store files
+.DS_Store

+ 0 - 1
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]: