Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

config precommit hook

appflowy717d53412b03
diff --git a/.githook/pre-commit b/.githook/pre-commit
deleted file mode 100755
index eb09ba97ff..0000000000
--- a/.githook/pre-commit
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env bash
-
-#flutter format .
-
diff --git a/.githook/pre-push b/.githook/pre-push
deleted file mode 100755
index 113d1e14bd..0000000000
--- a/.githook/pre-push
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env bash
-cd flutter-lib
-if [[ `git status --porcelain` ]]; then
- printf "\e[31;1m%s\e[0m\n" 'This script needs to run against committed code only. Please commit or stash you changes.'
- exit 1
-fi
-printf "\e[33;1m%s\e[0m\n" 'Running the Flutter analyzer'
-flutter analyze
-if [ $? -ne 0 ]; then
- printf "\e[31;1m%s\e[0m\n" 'Flutter analyzer error'
- exit 1
-fi
-printf "\e[33;1m%s\e[0m\n" 'Finished running the Flutter analyzer'
-printf "\e[33;1m%s\e[0m\n" 'Running unit tests'
-
-#current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
-#if [ "$current_branch" = "main" ]; then
-# echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
-# echo ""
-# echo " Should not push to main directly. Use Pull Request instead"
-# echo ""
-# echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
-# exit 1
-#fi
-
-
-
-#flutter test
-#if [ $? -ne 0 ]; then
-# printf "\e[31;1m%s\e[0m\n" 'Unit tests error'
-# exit 1
-#fi
-#printf "\e[33;1m%s\e[0m\n" 'Finished running unit tests'
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
index eb09ba97ff..92b37ec498 100755
--- a/.githooks/pre-commit
+++ b/.githooks/pre-commit
@@ -1,4 +1,34 @@
#!/usr/bin/env bash
#flutter format .
+##https://gist.github.com/benmccallum/28e4f216d9d72f5965133e6c43aaff6e
+limit=$(( 1 * 2**20 )) # 1MB
+function file_too_large(){
+ filename=$0
+ filesize=$(( $1 / 2**20 ))
+
+ cat <<HEREDOC
+
+ File $filename is $filesize MB, which is larger than github's maximum
+ file size (1 MB). We will not be able to push this file to Github.
+ Commit aborted
+HEREDOC
+
+}
+
+empty_tree=$( git hash-object -t tree /dev/null )
+if git rev-parse --verify HEAD > /dev/null 2>&1
+then
+ against=HEAD
+else
+ against=empty_tree
+fi
+
+for file in $( git diff-index --cached --name-only $against ); do
+ file_size=$( ls -la $file | awk '{ print $5 }')
+ if [ "$file_size" -gt "$limit" ]; then
+ file_too_large $filename $file_size
+ exit 1;
+ fi
+done
\ No newline at end of file
diff --git a/.githooks/pre-push b/.githooks/pre-push
index 72c666bcb0..1636fb8661 100755
--- a/.githooks/pre-push
+++ b/.githooks/pre-push
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-cd flutter-lib
+
if [[ `git status --porcelain` ]]; then
printf "\e[31;1m%s\e[0m\n" 'This script needs to run against committed code only. Please commit or stash you changes.'
exit 1