stonet2000 commited on
Commit
d70d870
·
1 Parent(s): 3bd1674

precommit hooks

Browse files
.pre-commit-config.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: check-added-large-files
6
+
7
+ - repo: local
8
+ hooks:
9
+ - id: zip-demos
10
+ name: zip-demos
11
+ description: zip demos
12
+ entry: hooks/zip_modified_demos.sh
13
+ language: script
14
+ types: [file]
15
+ verbose: true
hooks/zip_modified_demos.sh ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Get list of changed files from git
4
+ changed_files=$(git diff --cached --name-only)
5
+
6
+ # Track if any demos were changed
7
+ any_changes=false
8
+
9
+ # Check each demo folder and rezip if changes detected
10
+ for folder in demos/*; do
11
+ # Remove trailing slash
12
+ folder=${folder%/}
13
+ echo $folder
14
+ # Check if any changed files are in this folder
15
+ if echo "$changed_files" | grep -q "^$folder/"; then
16
+ echo "Changes detected in $folder, rezipping..."
17
+
18
+ # Remove existing zip if it exists
19
+ rm -f "$folder.zip"
20
+
21
+ # Create new zip archive
22
+ zip -r "$folder.zip" "$folder"
23
+
24
+ # Stage the new zip file
25
+ git add "$folder.zip"
26
+
27
+ any_changes=true
28
+ fi
29
+ done
30
+
31
+ if [ "$any_changes" = false ]; then
32
+ echo "No demo folders were modified, skipping zip creation"
33
+ exit 0
34
+ else
35
+ echo "Demo folders were modified"
36
+ exit 1
37
+ fi