Skip to content

Commit 1ce8e7e

Browse files
ajusta logica do bloqueio de merge do codenarc para quebrar apenas em p1 no diff
1 parent 5a4b61c commit 1ce8e7e

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

entrypoint.sh

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,26 @@ check_blocking_rules() {
8484
git diff --no-color -U0 HEAD~1 -- "$file" > /tmp/file_diff.txt 2>/dev/null || true
8585
fi
8686

87-
match=$(awk -v l="$line" '
88-
/^@@/ {
89-
if (match($0, /\+([0-9]+)(,([0-9]+))?/, m)) {
90-
start = m[1]
91-
len = (m[3]=="" ? 1 : m[3])
92-
if (l >= start && l < start+len) {
93-
print "hit"; exit
94-
}
95-
}
96-
}
97-
' /tmp/file_diff.txt)
87+
match=""
88+
if grep -q "^@@" /tmp/file_diff.txt; then
89+
while read -r diff_line; do
90+
if echo "$diff_line" | grep -q "^@@"; then
91+
range=$(echo "$diff_line" | sed 's/.*+\([0-9,]*\).*/\1/')
92+
if echo "$range" | grep -q ","; then
93+
start=$(echo "$range" | cut -d',' -f1)
94+
count=$(echo "$range" | cut -d',' -f2)
95+
else
96+
start="$range"
97+
count=1
98+
fi
99+
100+
if [ "$line" -ge "$start" ] && [ "$line" -lt "$((start + count))" ]; then
101+
match="hit"
102+
break
103+
fi
104+
fi
105+
done < /tmp/file_diff.txt
106+
fi
98107

99108
if [ "$match" = "hit" ]; then
100109
echo "🚨 Violacao P1 no diff: $file:$line"

0 commit comments

Comments
 (0)