Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to drop the colon #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ runs:
image: "Dockerfile"
args:
- ${{ inputs.case-sensitive }}
- ${{ inputs.require-colon }}
inputs:
terms:
description: "The pipe-delimited searchable terms to pass as a regex group to `git grep`."
Expand All @@ -18,3 +19,7 @@ inputs:
description: "Whether the searchable terms passed to `git grep` should be case-sensitive or not."
required: false
default: true
require-colon:
description: "Whether the terms must be followed by a colon."
required: false
default: true
10 changes: 9 additions & 1 deletion lib/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ echo "::add-matcher::git-grep-problem-matcher.json"


case_sensitive="${1}"
require_colon="${2}"

if [ ${case_sensitive} = false ]; then
case_sensitive="--ignore-case"
Expand All @@ -19,7 +20,14 @@ fi


tag=${INPUT_TERMS:=FIXME}
result=$(git grep --no-color ${case_sensitive} --line-number --extended-regexp -e "(${tag})+(:)" :^.github)

regex="(${tag})+"

if [ ${require_colon} = true ]; then
regex="${regex}(:)"
fi

result=$(git grep --no-color ${case_sensitive} --line-number --extended-regexp -e "${regex}" :^.github)

echo "${result}"

Expand Down