From 6fcc37e15ce80a73cda68ee3a1bfdff2ce6e7c38 Mon Sep 17 00:00:00 2001 From: MikeWallaceDev Date: Sun, 17 Jul 2022 16:54:49 -0400 Subject: [PATCH 1/3] fix: Made githook scripts executable --- .githooks/pre-commit | 4 +++- .githooks/pre-push | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 .githooks/pre-commit mode change 100644 => 100755 .githooks/pre-push diff --git a/.githooks/pre-commit b/.githooks/pre-commit old mode 100644 new mode 100755 index d7617246c9..d27345fe71 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,5 +1,7 @@ #!/usr/bin/env bash +echo "Running local AppFlowy pre-commit hook." + #flutter format . ##https://gist.github.com/benmccallum/28e4f216d9d72f5965133e6c43aaff6e limit=$(( 1 * 2**20 )) # 1MB @@ -31,4 +33,4 @@ for file in $( git diff-index --cached --name-only $against ); do file_too_large $filename $file_size exit 1; fi -done \ No newline at end of file +done diff --git a/.githooks/pre-push b/.githooks/pre-push old mode 100644 new mode 100755 index 1636fb8661..ad7d19a16e --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -1,15 +1,20 @@ #!/usr/bin/env bash +echo "Running local AppFlowy pre-push hook." + 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' From ff0c6a9d98be7d59dc4589ba3ff0bcf1238025bd Mon Sep 17 00:00:00 2001 From: MikeWallaceDev Date: Sun, 17 Jul 2022 20:16:12 -0400 Subject: [PATCH 2/3] feat: Added commit-msg hook This will call commitlint to validate commit messages --- .githooks/commit-msg | 26 ++++++++++++++++++++++++++ package.json | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100755 .githooks/commit-msg diff --git a/.githooks/commit-msg b/.githooks/commit-msg new file mode 100755 index 0000000000..24cd55c6b6 --- /dev/null +++ b/.githooks/commit-msg @@ -0,0 +1,26 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. + +echo "Running the AppFlowy commit-msg hook." + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} + +npx --no -- commitlint --edit $1 + +if [ $? -ne 0 ] +then + echo "Please fix your commit message to match AppFlowy coding standards" + exit 1 +fi + diff --git a/package.json b/package.json index c891bb7d81..0f3afaccbc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "devDependencies": { - "@commitlint/cli": "16.1.0", - "@commitlint/config-conventional": "16.0.0", + "@commitlint/cli": "^16.1.0", + "@commitlint/config-conventional": "^16.0.0", "husky": "7.0.4" } } From 5035075e143b84e48924180bb0be076f4e34e9f2 Mon Sep 17 00:00:00 2001 From: MikeWallaceDev Date: Sun, 17 Jul 2022 20:36:51 -0400 Subject: [PATCH 3/3] fix: removed references to Husky --- .husky/commit-msg | 4 ---- package.json | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100755 .husky/commit-msg diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100755 index 7fed48507b..0000000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx --no -- commitlint --edit diff --git a/package.json b/package.json index 0f3afaccbc..0f6a7fcafe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "devDependencies": { "@commitlint/cli": "^16.1.0", - "@commitlint/config-conventional": "^16.0.0", - "husky": "7.0.4" + "@commitlint/config-conventional": "^16.0.0" } }