Skip to content

Commit

Permalink
Add support for ugrep closes debian bug #1002509
Browse files Browse the repository at this point in the history
  • Loading branch information
vlajos committed Jan 12, 2022
1 parent 6801cb1 commit 6595833
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:3.8
FROM alpine:3.15
MAINTAINER Lajos Veres <vlajos@gmail.com>

RUN apk --no-cache add bash grep sed findutils coreutils diffutils git
RUN apk --no-cache add bash grep sed findutils coreutils diffutils git ugrep

RUN mkdir /misspell-fixer

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ A little more comprehensive list:
* rm, cp, mv
* xargs
* git (for respecting .gitignore files)
* ugrep (optional)

### Authors

Expand Down
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
misspell-fixer (0.5-1) unstable; urgency=medium

* Use ugrep if available. (#1002509)
* Update docs.

-- Lajos Veres <vlajos+debian@gmail.com> Thu, 06 Jan 2022 19:49:32 +0000

misspell-fixer (0.4-1) unstable; urgency=medium

* Option to respect .gitignore
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Package: misspell-fixer
Architecture: all
Multi-Arch: foreign
Depends: grep (>= 2.28), ${misc:Depends}
Recommends: git
Recommends: git, ugrep
Description: Tool for fixing common misspellings, typos in source code
Utility to fix common misspellings, typos in source code.
There are lots of typical misspellings in program code.
Expand Down
4 changes: 3 additions & 1 deletion doc/misspell-fixer.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "misspell-fixer" "" "February 2021" "" "misspell-fixer"
.TH "misspell-fixer" "" "January 2022" "" "misspell-fixer"
.SH NAME
misspell-fixer - misspell-fixer
.P
Expand Down Expand Up @@ -246,6 +246,8 @@ rm, cp, mv
xargs
.IP "\[ci]" 4
git (for respecting \.gitignore files)
.IP "\[ci]" 4
ugrep (optional)
.IP "" 0
.SS "Authors"
.IP "\[ci]" 4
Expand Down
9 changes: 5 additions & 4 deletions lib/initialisation_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ function initialise_variables {
echo '/// ///' >$tmpfile.git.ignore
trap 'rm -f $tmpfile.git.ignore' EXIT

GREP=$(ggrep --version >/dev/null 2>&1 && \
echo 'ggrep' || \
echo 'grep')
GREP=$((ugrep --version >/dev/null 2>&1 && echo 'ugrep') \
|| (ggrep --version >/dev/null 2>&1 && echo 'ggrep') \
|| echo 'grep')
export GREP
}
Expand Down Expand Up @@ -278,7 +278,8 @@ function check_grep_version {
warning "!! Your grep version is $current_version"\
"which is less than the optimal: $required_version."\
"This may degrade misspell fixer's performance"\
"significantly! (100x) !!"
"significantly! (100x) !! Alternatively install ugrep "\
"which is even quicker."
fi
}

Expand Down
3 changes: 2 additions & 1 deletion lib/main_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ function execute_prefiltering {
sort\
-u\
"$iteration_tmp_file.matches"\
"$iteration_tmp_file.matches.word_limited"\
"$iteration_tmp_file.matches.word_limited" |\
"$GREP" ':' \
>"$iteration_tmp_file.matches.all"
}

Expand Down
3 changes: 1 addition & 2 deletions test/expected.debug.output
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
+++++ apply_whitelist_on_prefiltered_list .misspell-fixer.X.X
+++++ check_grep_version
+++++ check_sed_arguments
+++++ current_version=X.X
+++++ cut -d : -f X .misspell-fixer.X.X.matches.all
+++++ echo 'misspell-fixer: Iteration X: done.'
+++++ echo 'misspell-fixer: Iteration X: prefiltering.'
Expand All @@ -58,6 +57,7 @@
+++++ grep -Fvx -f .misspell-fixer.X.git.ignore
+++++ grep -q illegal
+++++ grep -v '\\b' .misspell-fixer.X.prepared.sed.all_rules
+++++ grep :
+++++ iterate_through_prefiltered_files X .misspell-fixer.X.X
+++++ iterate_through_targets list_files_from_find X '' /dev/null
+++++ list_files_from_find ''
Expand All @@ -76,7 +76,6 @@
+++++ local required_version=X.X
+++++ local retval=X
+++++ prepare_rules_for_prefiltering
+++++ printf '%s\n%s\n' X.X X.X
+++++ printf '%s\X' work/D.txt
+++++ printf '%s\X' work/g.txt
+++++ printf '%s\X' work/R.txt
Expand Down
13 changes: 11 additions & 2 deletions test/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ runAndCompareOutput(){
diff -ruwb $TEMP/expected/ $TEMP/work/
assertTrue 'Expected output differs.' $?

sed -e 's/[0-9]\+/X/g' -e 's/X -X$/X +X/g' "$TEST_OUTPUT" |\
grep -v -e kcov -e 'grep -vh bin/sed' -e "Your grep version is" \
sed \
-e 's/[0-9]\+/X/g' \
-e 's/X -X$/X +X/g' \
-e 's/ugrep/grep/g' \
"$TEST_OUTPUT" |\
grep -v \
-e kcov \
-e 'grep -vh bin/sed' \
-e 'current_version=' \
-e 'Your grep version is' \
-e '%s\\n%s\\n' \
>"$TEST_OUTPUT.standard"
if [[ "$3" = "1" ]]; then
sort -f "$TEST_OUTPUT.standard" >"$TEST_OUTPUT.standard.sorted"
Expand Down

0 comments on commit 6595833

Please sign in to comment.