It would appear from casual review to be duplicating the original line number and using it for the final line number too. It should be line 12 in the revised text. This pattern holds true with much larger files with many matches, fwiw.
And likewise, it shows the wrong output with --as-numbered-lines:
I'm trying to use grepdiff for CI change analysis, and it appears ideal for this scenario. In fact it works perfectly, but is placing the messages on the wrong lines:
# compare to see if the pattern is in the added lines
git diff origin/${{ github.base_ref }} --no-ext-diff --no-color --unified --text --no-prefix $file | \
grepdiff "${pattern}" --output-matching=hunk --only-match=additions --as-numbered-lines=after | \
grep -e "${pattern}" | \
while read -r get_line; do
linenum=$(echo $get_line| cut -d: -f1)
echo "::error file=${file},line=${linenum}::${obsolete_patterns[$pattern]}"
done
Grepdiff is calculating the wrong lines when using the
--as-numbered-lines
outputRecreation scenario
I've minimized this to as small of a document as demonstrates the issue. Start with an empty repo and original text
Now modify this file to insert additional lines (such that the line numbers would adjust) and adjust a target function you'd be searching for.
Observe that the line counts are correct in both outputs.
See grepdiff break the lines
The line count issue first appears with
grepdiff --output-matching=hunk
It would appear from casual review to be duplicating the original line number and using it for the final line number too. It should be line 12 in the revised text. This pattern holds true with much larger files with many matches, fwiw.
And likewise, it shows the wrong output with
--as-numbered-lines
:Use case
I'm trying to use
grepdiff
for CI change analysis, and it appears ideal for this scenario. In fact it works perfectly, but is placing the messages on the wrong lines: