Skip to content

Commit 98ab7a5

Browse files
committed
fix(pre-commit): update the pre-commit script
1 parent 442d42e commit 98ab7a5

9 files changed

+29
-17
lines changed

.github/workflows/check_lib_versions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
echo "prerelease: ${{ steps.last_release.outputs.prerelease }}"
2727
echo "url: ${{ steps.last_release.outputs.url }}"
2828
- name: Check & Compare versions
29-
run: bash ./.github/scripts/check_lib_versions.sh --latest_version=${{ steps.last_release.outputs.tag_name }}
29+
run: bash ./tools/check_lib_versions.sh --latest_version=${{ steps.last_release.outputs.tag_name }}

.gitlab/tools/executable-list.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,33 @@ repos:
7777
hooks:
7878
- id: check-executables
7979
name: Check File Permissions
80-
entry: .gitlab/tools/check_executables.py --action executables
80+
entry: ./tools/check_executables.py --action executables
8181
language: python
8282
types: [executable]
8383
exclude: '\.pre-commit/.+'
8484
- id: check-executable-list
8585
name: Validate executable-list.txt
86-
entry: .gitlab/tools/check_executables.py --action list
86+
entry: ./tools/check_executables.py --action list
8787
language: python
8888
pass_filenames: false
8989
always_run: true
9090
- id: sync-conf-files
9191
name: Update when configuration files change
92-
entry: python3 tools/sync_conf_files.py ./ ./
92+
entry: python3 ./tools/sync_conf_files.py ./ ./
9393
language: system
9494
files: '.*esp_panel_(board_custom|board_supported|drivers)_conf\.h'
9595
- id: sync-template-files
9696
name: Update when template files change
97-
entry: python3 tools/sync_conf_files.py ./template_files ./
97+
entry: python3 ./tools/sync_conf_files.py ./template_files ./
9898
language: system
9999
files: '(.*esp_utils_conf\.h|.*lv_conf\.h|.*lvgl_v8_port\.cpp|.*lvgl_v8_port\.h)'
100100
- id: check-file-versions
101101
name: Update when versions change
102-
entry: python3 tools/check_file_version.py ./
102+
entry: python3 ./tools/check_file_version.py ./
103103
language: system
104104
files: '(.*esp_panel_(board_custom|board_supported|drivers)_conf\.h|library.properties|.*esp_panel_versions.h)'
105105
- id: check-library-versions
106106
name: Check library versions
107-
entry: ./.github/scripts/check_lib_versions.sh
107+
entry: ./tools/check_lib_versions.sh
108108
language: system
109109
files: '(idf_component.yml|library.properties)'

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Bugfixes:
66

77
* fix(io_expander): remove incompatible header (#175)
8+
* fix(pre-commit): update the pre-commit script
89

910
## v1.0.1 - 2025-03-13
1011

.gitlab/tools/check_executables.py renamed to tools/check_executables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _strip_each_item(iterable: Iterable) -> List:
2525

2626

2727
COMPONENT_PATH = os.getenv('COMPONENT_PATH', os.getcwd())
28-
EXECUTABLE_LIST_FN = os.path.join(COMPONENT_PATH, '.gitlab/tools/executable-list.txt')
28+
EXECUTABLE_LIST_FN = os.path.join(COMPONENT_PATH, 'tools/executable-list.txt')
2929
known_executables = _strip_each_item(open(EXECUTABLE_LIST_FN).readlines())
3030

3131

File renamed without changes.

tools/executable-list.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.gitlab/tools/check_readme_links.py
2+
.gitlab/tools/push_to_github.sh
3+
4+
tools/check_executables.py
5+
tools/check_file_version.py
6+
tools/check_lib_versions.sh
7+
tools/sync_conf_files.py
File renamed without changes.

tools/sync_conf_files.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
'./examples/platformio/lvgl_v8_port/src/lv_conf.h',
1111
]
1212
exclude_dirs = [
13-
'./build',
14-
'./examples/platformio/lvgl_v8_port/.pio',
13+
r'.*build.*',
14+
r'.*pio.*',
1515
]
1616

1717

@@ -25,13 +25,21 @@ def is_same_path(path1, path2):
2525

2626

2727
def is_in_directory(file_path, directory):
28-
directory = os.path.realpath(directory)
28+
import re
2929
file_path = os.path.realpath(file_path)
3030

31-
return file_path.startswith(directory)
31+
# Check if the file path matches any of the exclude directory patterns
32+
for pattern in exclude_dirs:
33+
if re.search(pattern, file_path):
34+
return True
35+
return False
3236

3337

3438
def is_same_file(file1, file2):
39+
# Check if both files exist
40+
if not os.path.exists(file1) or not os.path.exists(file2):
41+
return False
42+
3543
with open(file1, 'r') as f1, open(file2, 'r') as f2:
3644
file1_content = f1.read()
3745
file2_content = f2.read()
@@ -53,7 +61,7 @@ def replace_files(template_directory, search_directory, file_path):
5361
filename = os.path.basename(file_path)
5462
src_file = os.path.join(template_directory, filename)
5563

56-
if is_exclude_file(file_path):
64+
if is_exclude_file(file_path) or not os.path.exists(src_file):
5765
print(f"Skip '{file_path}'")
5866
return
5967

0 commit comments

Comments
 (0)