2021-07-06 14:56:56 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-07-25 19:20:55 +03:00
|
|
|
YELLOW="\e[93m"
|
|
|
|
GREEN="\e[32m"
|
|
|
|
RED="\e[31m"
|
|
|
|
ENDCOLOR="\e[0m"
|
|
|
|
|
|
|
|
printMessage() {
|
|
|
|
printf "${YELLOW}AppFlowy : $1${ENDCOLOR}\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
printSuccess() {
|
|
|
|
printf "${GREEN}AppFlowy : $1${ENDCOLOR}\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
printError() {
|
|
|
|
printf "${RED}AppFlowy : $1${ENDCOLOR}\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
printMessage "Running local AppFlowy pre-commit hook."
|
2022-07-17 23:54:49 +03:00
|
|
|
|
2021-07-06 14:56:56 +03:00
|
|
|
#flutter format .
|
2021-07-08 09:14:03 +03:00
|
|
|
##https://gist.github.com/benmccallum/28e4f216d9d72f5965133e6c43aaff6e
|
|
|
|
limit=$(( 1 * 2**20 )) # 1MB
|
2021-07-06 14:56:56 +03:00
|
|
|
|
2021-07-08 09:14:03 +03:00
|
|
|
function file_too_large(){
|
|
|
|
filename=$0
|
|
|
|
filesize=$(( $1 / 2**20 ))
|
|
|
|
|
|
|
|
cat <<HEREDOC
|
|
|
|
|
|
|
|
File $filename is $filesize MB, which is larger than github's maximum
|
Correct the capitalization of GitHub
To accomplish this task, I ran the following command (on macOS):
find . -type f -print0 | xargs -0 sed -i '' 's/Github/GitHub/g'
GitHub, for better or worse, decided that the way their company is
spelled is with a capital "G" and a capital "H" and it's their name so
they get to do that if they want.
When I went to check out AppFlowy's web site, I noticed that GitHub
wasn't spelled correctly, and for me, this made the project feel less
than polished and myself reluctant to try it out. However, there is only
one way to find out about the project: I [opened a ticket]. And BAM! It
was resolved in mere hours by @annieappflowy. Nice.
With fresh motivation to check out the project, I downloaded the app
and...found myself staring at the same issue on the first screen of the
app. Well, as I was a bit flippant with the issue I opened up for the
web site misspellings, I decided to fix this one myself.
[opened a ticket]: https://github.com/AppFlowy-IO/appflowy/issues/118
2021-12-05 01:43:41 +03:00
|
|
|
file size (1 MB). We will not be able to push this file to GitHub.
|
2021-07-08 09:14:03 +03:00
|
|
|
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
|
2022-07-17 23:54:49 +03:00
|
|
|
done
|