|
1 | | -# #!/usr/bin/env bash |
2 | | -# set -euo pipefail |
3 | | - |
4 | | -# # Create commitlint config if it doesn't exist |
5 | | -# if [ ! -f "$(git rev-parse --show-toplevel)/commitlint.config.js" ]; then |
6 | | -# cat << 'CONFIG_EOF' > "$(git rev-parse --show-toplevel)/commitlint.config.js" |
7 | | -# module.exports = { |
8 | | -# extends: ['@commitlint/config-conventional'], |
9 | | -# rules: { |
10 | | -# 'type-enum': [2, 'always', [ |
11 | | -# 'feat', // A new feature |
12 | | -# 'fix', // A bug fix |
13 | | -# 'docs', // Documentation only changes |
14 | | -# 'style', // Changes that do not affect code meaning |
15 | | -# 'refactor', // A code change that neither fixes a bug nor adds a feature |
16 | | -# 'perf', // A code change that improves performance |
17 | | -# 'test', // Adding missing tests or correcting existing tests |
18 | | -# 'build', // Build system or external dependencies |
19 | | -# 'ci', // CI configuration changes |
20 | | -# 'chore', // Other changes that don't modify src or test files |
21 | | -# 'revert', // Reverts a previous commit |
22 | | -# ]], |
23 | | -# 'type-case': [2, 'always', 'lowerCase'], |
24 | | -# 'type-empty': [2, 'never'], |
25 | | -# 'scope-case': [2, 'always', 'lowerCase'], |
26 | | -# 'subject-empty': [2, 'never'], |
27 | | -# 'subject-full-stop': [2, 'never', '.'], |
28 | | -# 'header-max-length': [2, 'always', 72], |
29 | | -# }, |
30 | | -# }; |
31 | | -# CONFIG_EOF |
32 | | -# echo "✅ Created commitlint.config.js in repository root" |
33 | | -# fi |
34 | | - |
35 | | -# # Ensure commitlint is available |
36 | | -# if ! command -v commitlint >/dev/null 2>&1; then |
37 | | -# echo "⚙️ Installing commitlint globally..." |
38 | | -# npm install -g @commitlint/cli @commitlint/config-conventional >/dev/null 2>&1 |
39 | | -# fi |
40 | | - |
41 | | -# # Read commit message |
42 | | -# commit_msg_file="$1" |
43 | | -# commit_msg=$(cat "$commit_msg_file") |
44 | | - |
45 | | -# # Run commitlint and capture output (important!) |
46 | | -# lint_output=$(echo "$commit_msg" | commitlint 2>&1) || lint_status=$? |
47 | | - |
48 | | -# if [ "${lint_status:-0}" -ne 0 ]; then |
49 | | -# RED='\033[0;31m' |
50 | | -# YELLOW='\033[1;33m' |
51 | | -# NC='\033[0m' |
52 | | - |
53 | | -# echo -e "${RED}\n❌ Commit message format error detected.${NC}" |
54 | | -# echo -e "${YELLOW}\nCommit message must follow the Conventional Commit format:\n${NC}" |
55 | | -# echo -e "${YELLOW} type(scope): subject${NC}" |
56 | | -# echo -e "\n${YELLOW}Types:${NC}" |
57 | | -# echo " feat : A new feature" |
58 | | -# echo " fix : A bug fix" |
59 | | -# echo " docs : Documentation only changes" |
60 | | -# echo " style : Changes that do not affect code meaning" |
61 | | -# echo " refactor : Code change that neither fixes a bug nor adds a feature" |
62 | | -# echo " perf : Code change that improves performance" |
63 | | -# echo " test : Adding or correcting tests" |
64 | | -# echo " build : Changes to the build system or external dependencies" |
65 | | -# echo " ci : CI configuration or scripts" |
66 | | -# echo " chore : Other changes that don't modify src or test files" |
67 | | -# echo " revert : Reverts a previous commit" |
68 | | -# echo -e "\n${YELLOW}Examples:${NC}" |
69 | | -# echo " feat(auth): add password reset functionality" |
70 | | -# echo " fix(api): handle null server response" |
71 | | -# echo " docs(readme): update installation instructions" |
72 | | - |
73 | | -# echo -e "\n${RED}Commitlint output:${NC}" |
74 | | -# echo "$lint_output" |
75 | | - |
76 | | -# echo -e "\n${RED}❗ Please fix your commit message and try again.${NC}" |
77 | | -# exit 1 |
78 | | -# else |
79 | | -# echo -e "\033[0;32m✅ Commit message passed Conventional Commit check.\033[0m" |
80 | | -# fi |
81 | | - |
82 | | - |
83 | 1 | #!/usr/bin/env bash |
84 | 2 | set -euo pipefail |
85 | 3 |
|
|
0 commit comments