Browse Source

Use xargs instead of mapfile for CI/git hook examples

pull/30/head
Fredrik Ekre 1 year ago
parent
commit
02f0457782
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 4
      .github/workflows/Check.yml
  2. 14
      README.md

4
.github/workflows/Check.yml

@ -36,11 +36,11 @@ jobs: @@ -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' }}

14
README.md

@ -158,7 +158,7 @@ any of the input files are incorrectly formatted. As an example, the following i @@ -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
@ -192,10 +192,10 @@ jobs: @@ -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
@ -212,11 +212,9 @@ to automatically check formatting before committing. Here is an example hook @@ -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

Loading…
Cancel
Save