Skip to content

Commit d0050e0

Browse files
committed
[bug] Add special handling for windows to git utils
1 parent 6aa6d5f commit d0050e0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

kicad_lib_manager/utils/git_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Handles Git hooks directory detection and safe hook management.
44
"""
55

6+
import os
67
import subprocess
78
from datetime import datetime
89
from pathlib import Path
@@ -76,8 +77,8 @@ def backup_existing_hook(hook_path: Path) -> Path:
7677
# Copy the file content
7778
backup_path.write_text(hook_path.read_text(encoding="utf-8"))
7879

79-
# Preserve executable permissions
80-
if hook_path.stat().st_mode & 0o111: # Check if executable
80+
# Preserve executable permissions (Unix-like systems only)
81+
if os.name != 'nt' and hook_path.stat().st_mode & 0o111: # Not Windows and executable
8182
backup_path.chmod(0o755)
8283

8384
return backup_path

tests/test_git_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Tests for Git utility functions.
33
"""
44

5+
import os
56
from unittest.mock import Mock, patch
67

78
import pytest
@@ -41,7 +42,10 @@ def test_backup_existing_hook(self, tmp_path):
4142
assert backup_path != hook_file
4243
assert backup_path.read_text() == hook_content
4344
assert backup_path.name.startswith("post-merge.backup.")
44-
assert backup_path.stat().st_mode & 0o111 # Check executable bit
45+
46+
# Check executable bit only on Unix-like systems
47+
if os.name != 'nt': # Not Windows
48+
assert backup_path.stat().st_mode & 0o111 # Check executable bit
4549

4650
def test_merge_hook_content_new_content(self):
4751
"""Test merging when no KiLM content exists."""

0 commit comments

Comments
 (0)