Skip to content

Commit

Permalink
Use xargs instead of mapfile for CI/git hook examples
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Jul 30, 2024
1 parent ad5fe4d commit 02f0457
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/Check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
julia --color=yes --project --code-coverage=${{ env.coverage_flag }} -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
- name: Run Runic
run: |
julia --color=yes --project --code-coverage=${{ env.coverage_flag }} -m Runic --check --diff $(git ls-files -- '*.jl')
git ls-files -z -- '*.jl' | xargs -0 julia --color=yes --project --code-coverage=${{ env.coverage_flag }} -m Runic --check --diff
if: ${{ matrix.version == 'nightly' }}
- name: Run Runic
run: |
julia --color=yes --project --code-coverage=${{ env.coverage_flag }} -e 'using Runic; exit(Runic.main(ARGS))' -- --check --diff $(git ls-files -- '*.jl')
git ls-files -z -- '*.jl' | xargs -0 julia --color=yes --project --code-coverage=${{ env.coverage_flag }} -e 'using Runic; exit(Runic.main(ARGS))' -- --check --diff
if: ${{ matrix.version != 'nightly' }}
- uses: julia-actions/julia-processcoverage@v1
if: ${{ matrix.version == '1' || matrix.version == 'nightly' }}
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ any of the input files are incorrectly formatted. As an example, the following i
can be used:
```sh
julia -m Runic --check --diff $(git ls-files -- '*.jl')
git ls-files -z -- '*.jl' | xargs -0 julia -m Runic --check --diff
```
This will run Runic's check mode (`--check`) on all `.jl` files in the repository and print
Expand Down Expand Up @@ -192,10 +192,10 @@ jobs:
- uses: julia-actions/cache@v2
- name: Install Runic
run: |
julia --color=yes -e 'using Pkg; Pkg.add(url = "https://github.com/fredrikekre/Runic.jl")'
julia --color=yes --project=@runic -e 'using Pkg; Pkg.add(url = "https://github.com/fredrikekre/Runic.jl")'
- name: Run Runic
run: |
julia --color=yes -m Runic --check --diff $(git ls-files -- '*.jl')
git ls-files -z -- '*.jl' | xargs -0 julia --project=@runic -m Runic --check --diff
```
### Git Hooks
Expand All @@ -212,11 +212,9 @@ to automatically check formatting before committing. Here is an example hook
exec 1>&2
# Run Runic on added and modified files
mapfile -t files < <(git diff-index --name-only --diff-filter=AM master | grep '\.jl$')
if [ ${#files[@]} -gt 0 ]; then
julia --project=@runic -m Runic --check --diff "${files[@]}"
fi
git diff-index -z --name-only --diff-filter=AM master | \
grep -z '\.jl$' | \
xargs -0 --no-run-if-empty -p julia --project=@runic -m Runic --check --diff
```
## Formatting specification
Expand Down

0 comments on commit 02f0457

Please sign in to comment.