Skip to content

Commit 341c96b

Browse files
committed
Fix commit checker false positive for bypassing
This replaces broad text matching with targeted 'WIP:' prefix detection to avoid flagging commits that document '--no-verify' functionality. Change-Id: Iec813848db801be22963403a0a33859886c9240a
1 parent a7c3047 commit 341c96b

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

scripts/check-commitlog.sh

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
# This script checks:
44
# 1. Change-Id presence (indicates commit-msg hook processing)
5-
# 2. Commit message quality (indicates pre-commit hook compliance)
6-
# 3. Bypass detection (detects --no-verify usage or web interface commits)
5+
# 2. Commit message quality (subject line format and length)
6+
# 3. WIP commits detection (work-in-progress commits that start with WIP:)
7+
# 4. GitHub web interface usage (commits without proper hooks)
8+
# 5. Queue.c modifications require descriptive commit body
79
#
810
# Merge commits are excluded from this check.
911

@@ -23,31 +25,9 @@ BASE_COMMIT="0b8be2c15160c216e8b6ec82c99a000e81c0e429"
2325
# Get a list of non-merge commit hashes after BASE_COMMIT.
2426
commits=$(git rev-list --no-merges "${BASE_COMMIT}"..HEAD)
2527

26-
# Hook bypass detection patterns
27-
BYPASS_INDICATORS=(
28-
"--no-verify"
29-
"WIP"
30-
)
31-
32-
# Quality patterns that indicate hook processing
33-
PROBLEMATIC_PATTERNS=(
34-
'^[a-z]' # Uncapitalized subjects
35-
'\.$' # Ending with period
36-
'^.{1,10}$' # Too short subjects
37-
'^.{80,}' # Too long subjects
38-
'^(Update|Fix|Change|Modify) [a-zA-Z0-9_-]+\.(c|h)$' # Generic filename updates
39-
)
40-
4128
# Early exit if no commits to check
4229
[[ -z "$commits" ]] && { echo -e "${GREEN}No commits to check.${NC}"; exit 0; }
4330

44-
# Pre-compute indicator patterns for faster matching
45-
bypass_pattern=""
46-
for indicator in "${BYPASS_INDICATORS[@]}"; do
47-
bypass_pattern+="|${indicator,,}"
48-
done
49-
bypass_pattern="${bypass_pattern#|}"
50-
5131
# Ultra-fast approach: minimize git calls and parsing overhead
5232
failed=0
5333
warnings=0
@@ -122,11 +102,11 @@ for commit in "${!commit_cache[@]}"; do
122102
((failed++))
123103
fi
124104

125-
# Check 2: Bypass indicators (single pattern match)
126-
full_msg_lower="${full_msg,,}"
127-
if [[ "$full_msg_lower" =~ ($bypass_pattern) ]]; then
105+
# Check 2: Bypass indicators - only for actual WIP commits
106+
# Skip commits that are documenting features (like this commit checker itself)
107+
if [[ "$subject" =~ ^WIP[[:space:]]*: ]] || [[ "$subject" =~ ^wip[[:space:]]*: ]]; then
128108
has_warnings=1
129-
warning_list+="Contains bypass indicator: '${BASH_REMATCH[1]}'|"
109+
warning_list+="Work in progress commit|"
130110
((warnings++))
131111
fi
132112

scripts/checksums

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
25e7d2797e09bfafa0c0dee70111104648faec9d queue.h
22
b26e079496803ebe318174bda5850d2cce1fd0c1 list.h
3-
c286e18579b6461fc289732cee4a18a916f79659 scripts/check-commitlog.sh
3+
94041f5a62a086d53799467e1d08e2507a2067b6 scripts/check-commitlog.sh

0 commit comments

Comments
 (0)