Improve `grep` snippet for MR template `New Version of gitlab-styles`
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
What does this MR do and why?
While working on !179410 (merged), I noticed the grep --perl-regex ... provided on the MR template doesn't work as expected.
The 1st commit 0b28ee32 fixes the regex, and 2nd commit c7ba5fad proposes switching to --extended-regexp to make it work for BSD grep (macOS users) in addition to GNU grep.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
For 0b28ee32
| Before | After |
|---|---|
|
|
For c7ba5fad
| OS | Before | After |
|---|---|---|
| Ubuntu |
|
|
| macOS |
|
|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Get example input like
wget https://gitlab.com/-/project/278964/uploads/8c8bbab787b494279f21960d7b6e36bd/raw_job_output.log(from !179410 (merged)) - Run
grep --perl-regexp -o ":\d+\d+: \w: \[\S+\] ([\w/]+)" raw_job_output.log | awk '{print $4}' | sort | uniq -cto see incorrect output - Run
grep --perl-regexp -o ":\d+:\d+: \w: \[\S+\] ([\w/]+)" raw_job_output.log | awk '{print $4}' | sort | uniq -cto see correct output - Run
grep --extended-regexp -o ":[0-9]+:[0-9]+: [[:alnum:]]: \[[^[:space:]]+\] ([[:alnum:]/]+)" raw_job_output.log | awk '{print $4}' | sort | uniq -cto see the correct output. This works for BSD grep in addition to GNU grep.
Edited by Chou Yu Ta





