File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed
Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff 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 "
You can’t perform that action at this time.
0 commit comments