mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2025-12-26 16:07:57 +01:00
implement pre push hooks for checking for duplicate tilesets in maps
This commit is contained in:
7
.githooks/git-hooks-config.bat
Normal file
7
.githooks/git-hooks-config.bat
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# This script will config git hook path into specific folder in your project. This script will invoked by maven build.
|
||||
# @author : Mak Sophea
|
||||
# @version : 1.0#
|
||||
#
|
||||
echo "config git hooksPath to .githooks folder for commit-msg and pre-push"
|
||||
git config core.hooksPath .githooks
|
||||
7
.githooks/git-hooks-config.sh
Normal file
7
.githooks/git-hooks-config.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# This script will config git hook path into specific folder in your project. This script will invoked by maven build.
|
||||
# @author : Mak Sophea
|
||||
# @version : 1.0#
|
||||
#
|
||||
echo "config git hooksPath to .githooks folder for commit-msg and pre-push"
|
||||
git config core.hooksPath .githooks
|
||||
34
.githooks/pre-push
Executable file
34
.githooks/pre-push
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# @author: OMGeeky
|
||||
# @created: 2023-10-15
|
||||
# @description: A script to check if a tileset is duplicated in a Tiled map.
|
||||
|
||||
echo "Checking for duplicate tilesets..."
|
||||
|
||||
# The folder to scan
|
||||
folder="AndorsTrail/res/xml/*.tmx"
|
||||
# The regex pattern to look for
|
||||
regex='(?s)(map_\w*").*\1'
|
||||
found=0
|
||||
# Iterate over the files in the folder
|
||||
for file in $folder; do
|
||||
# If the file matches the regex pattern, print a warning and exit with a nonzero status
|
||||
# echo "Checking file $file"
|
||||
if grep -Pzq "$regex" "$file"; then
|
||||
echo "Warning: File $file contains the regex pattern!"
|
||||
found=$((found + 1))
|
||||
# Print each location where the pattern is found
|
||||
grep -Pzao '(?s)(map_\w*").*\1' "$file" | awk -F "\"" '{print $1; exit}'
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
if [ $found -gt 0 ]; then
|
||||
echo "Duplicate tilesets found in $found files."
|
||||
exit 1
|
||||
else
|
||||
echo "No duplicate tilesets found."
|
||||
fi
|
||||
|
||||
# If no files matched the regex pattern, exit with a zero status
|
||||
exit 0
|
||||
Reference in New Issue
Block a user