-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(repo): add
TODO
& FIXME
checker
1 parent
90d50ab
commit a0dafbd
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: TODO Check | ||
on: | ||
push: | ||
branches: ["main"] | ||
paths: | ||
- '**/*.rs' | ||
- 'src/**/*' | ||
pull_request: | ||
paths: | ||
- '**/*.rs' | ||
- 'src/**/*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-todos: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set outputs | ||
id: vars | ||
run: | | ||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
echo "todos_old=$(cat .todos)" >> $GITHUB_OUTPUT | ||
- run: sh check_todos.sh --count | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: .todos for ${{ steps.vars.outputs.sha_short }} | ||
file_pattern: '.todos' | ||
|
||
- name: Check TODOs & FIXMEs | ||
run: | | ||
if [ "$(cat .todos)" -gt "$todos_old" ]; then | ||
echo "TODO & FIXME count increased." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#! /bin/sh | ||
if [ ! -f '.todos' ]; then | ||
echo "run this in nvrs' parent directory." | ||
exit 1 | ||
fi | ||
|
||
todo_grep=$(grep -rni 'TODO\|FIXME' ./* --exclude-dir=target --exclude=banner.webp --exclude=check_todos.sh | cut -d':' -f1,2) | ||
|
||
if [ -z "$todo_grep" ]; then | ||
echo 0 > .todos | ||
exit 0 | ||
fi | ||
|
||
echo "$todo_grep" | wc -l > .todos | ||
|
||
if [ "$1" = '--count' ]; then | ||
exit 0 | ||
fi | ||
|
||
if ! command -v 'bat'; then | ||
echo "bat not found." | ||
exit 1 | ||
fi | ||
|
||
for todo in $todo_grep; do | ||
file=$(echo "$todo" | cut -d':' -f1 | cut -c 3-) | ||
line=$(echo "$todo" | cut -d':' -f2) | ||
|
||
if [ $(( line - 20 )) -lt 1 ]; then | ||
line_min=1 | ||
else | ||
line_min=$(( line - 20 )) | ||
fi | ||
|
||
clear | ||
bat "$file" -r "$line_min:$(( line + 20 ))" -H "$line" -P | ||
|
||
echo "hit ENTER to continue." | ||
read -r _ | ||
done |