Skip to content

Commit dcc7f60

Browse files
Wise-Wizardnamkyu1999S-ayanide
authored
Add Pre Commit Check (#4642)
* Removed unused strings in strings.en.yml Signed-off-by: Wise-Wizard <[email protected]> * Removed unncessary changes Signed-off-by: Wise-Wizard <[email protected]> * Removed Comments Signed-off-by: Wise-Wizard <[email protected]> --------- Signed-off-by: Wise-Wizard <[email protected]> Co-authored-by: Namkyu Park <[email protected]> Co-authored-by: Sayan Mondal <[email protected]>
1 parent 14c9808 commit dcc7f60

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

chaoscenter/web/.husky/pre-commit

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,31 @@
22
"$(dirname "$0")/_/husky.sh"
33

44
MATCH_PATH='chaoscenter/web/'
5+
STRINGS_FILE="chaoscenter/web/strings/strings.en.yaml"
6+
7+
check_and_delete_unused_strings() {
8+
TEMP_FILE=$(mktemp)
9+
grep -rEo '\b[a-zA-Z0-9_]+\b' chaoscenter/web/**/*.js > "$TEMP_FILE"
10+
UNUSED_STRINGS=$(grep -v '^#' "$STRINGS_FILE" | grep -vFf "$TEMP_FILE" | grep -oE '^[a-zA-Z0-9_]+')
11+
rm "$TEMP_FILE"
12+
13+
if [ -n "$UNUSED_STRINGS" ]; then
14+
echo "Unused strings found: $UNUSED_STRINGS"
15+
for UNUSED_STRING in $UNUSED_STRINGS; do
16+
sed -i "/$UNUSED_STRING:/d" "$STRINGS_FILE"
17+
done
18+
echo "Unused strings deleted from $STRINGS_FILE"
19+
else
20+
echo "No unused strings found in $STRINGS_FILE"
21+
fi
22+
}
23+
24+
check_and_delete_unused_strings
525

626
BRANCH=$(git rev-parse --abbrev-ref HEAD)
727

8-
if [ "$BRANCH" = "main" ]; then
9-
echo "\033[0;31;1mYou can't commit directly to main branch\033[0m"
28+
if [ "$BRANCH" = "master" ]; then
29+
echo "\033[0;31;1mYou can't commit directly to master branch\033[0m"
1030
exit 1
1131
fi
1232

@@ -24,4 +44,4 @@ if [ "$LITMUS_UI_FILE_CHANGES" -gt 0 ];
2444
cd ./chaoscenter/web && yarn lint-staged
2545
else
2646
echo "\033[0;93mSkipping husky pre-commit hook in $MATCH_PATH folder\033[0m"
27-
fi
47+
fi

0 commit comments

Comments
 (0)