mirror of
https://github.com/github/gitignore.git
synced 2026-11-14 05:41:50 +01:00
Merge pull request #4943 from github/dooleydevin/add-gitignore-template-linter
Add gitignore template linter
This commit is contained in:
3 files changed
+64
-2
No files matched your search
@@ -0,0 +1,62 @@
|
|||||||
|
name: Gitignore formatting
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
formatting:
|
||||||
|
name: Check gitignore formatting
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||||
|
with:
|
||||||
|
python-version: "3.15.2"
|
||||||
|
|
||||||
|
- name: Install formatting tools
|
||||||
|
run: python -m pip install pre-commit-hooks==6.0.0
|
||||||
|
|
||||||
|
- name: Install dos2unix
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install --yes dos2unix
|
||||||
|
|
||||||
|
- name: Check all gitignore files recursively
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
git ls-files -z -- ':(top,glob)**/*.gitignore' > "$RUNNER_TEMP/gitignore-files"
|
||||||
|
mapfile -d '' -t files < "$RUNNER_TEMP/gitignore-files"
|
||||||
|
|
||||||
|
if (( ${#files[@]} == 0 )); then
|
||||||
|
echo "::error::No gitignore files found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Checking ${#files[@]} gitignore files."
|
||||||
|
|
||||||
|
status=0
|
||||||
|
if ! dos2unix --keep-bom -- "${files[@]}" > "$RUNNER_TEMP/dos2unix.log" 2>&1; then
|
||||||
|
cat "$RUNNER_TEMP/dos2unix.log" >&2
|
||||||
|
status=1
|
||||||
|
fi
|
||||||
|
trailing-whitespace-fixer -- "${files[@]}" || status=1
|
||||||
|
end-of-file-fixer -- "${files[@]}" || status=1
|
||||||
|
|
||||||
|
git --no-pager diff --no-ext-diff --exit-code -- "${files[@]}" || status=1
|
||||||
|
|
||||||
|
if (( status != 0 )); then
|
||||||
|
echo "::error::Formatting checks failed. See tool output and diff above."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit "$status"
|
||||||
+1
-1
@@ -49,7 +49,7 @@ po/*~
|
|||||||
# RStudio Connect folder
|
# RStudio Connect folder
|
||||||
rsconnect/
|
rsconnect/
|
||||||
|
|
||||||
# compiled code
|
# compiled code
|
||||||
src/*.o
|
src/*.o
|
||||||
src/*.so
|
src/*.so
|
||||||
src/*.dll
|
src/*.dll
|
||||||
@@ -19,4 +19,4 @@
|
|||||||
# Python / build artifacts
|
# Python / build artifacts
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
*.pyo
|
*.pyo
|
||||||
Reference in new issue
Block a user