Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't discard commit message on lint fail (#13953)
If we fail a commit message, we basically throw it away, which is frustrating if the commit message was more than trivial, which good commit messages often are. Instead, offer the developer a command to recover and re-edit their commit message.
- Loading branch information
1 parent
4bfb438
commit 1a6884a
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn commitlint --edit $1 | ||
BOLD_RED="\033[1;31m" | ||
BOLD_WHITE="\033[1;37m" | ||
YELLOW="\033[33m" | ||
WHITE="\033[37m" | ||
RESET="\033[0m" | ||
|
||
exitCode=0 | ||
yarn commitlint --edit $1 || exitCode="$?" | ||
|
||
if [ $exitCode -ne 0 ]; then | ||
echo "${BOLD_RED}!${BOLD_WHITE} Linting errors found in commit message!${RESET}" | ||
echo "${YELLOW}❯${RESET} Commit stored in .git/COMMIT_EDITMESSAGE" | ||
echo "${YELLOW}❯${RESET} You can run the following command to update your commit message:" | ||
echo "npm run fix-commit" | ||
fi | ||
|
||
exit $exitCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters