]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
⬆️ Use prek as a pre-commit alternative (#14572)
authorSebastián Ramírez <tiangolo@gmail.com>
Fri, 19 Dec 2025 12:44:55 +0000 (04:44 -0800)
committerGitHub <noreply@github.com>
Fri, 19 Dec 2025 12:44:55 +0000 (12:44 +0000)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
.github/workflows/pre-commit.yml
requirements.txt

index fa0574d7d188b652ce4413a4c61df9f13af72a65..e628ce541dd92903495f54847cf6bbe62ece7925 100644 (file)
@@ -21,14 +21,21 @@ jobs:
         name: Checkout PR for own repo
         if: env.IS_FORK == 'false'
         with:
-          # To be able to commit it needs more than the last commit
+          # To be able to commit it needs to fetch the head of the branch, not the
+          # merge commit
           ref: ${{ github.head_ref }}
+          # And it needs the full history to be able to compute diffs
+          fetch-depth: 0
           # A token other than the default GITHUB_TOKEN is needed to be able to trigger CI
           token: ${{ secrets.PRE_COMMIT }}
       # pre-commit lite ci needs the default checkout configs to work
       - uses: actions/checkout@v5
         name: Checkout PR for fork
         if: env.IS_FORK == 'true'
+        with:
+        # To be able to commit it needs the head branch of the PR, the remote one
+          ref: ${{ github.event.pull_request.head.sha }}
+          fetch-depth: 0
       - name: Set up Python
         uses: actions/setup-python@v6
         with:
@@ -44,12 +51,9 @@ jobs:
         run: |
           uv venv
           uv pip install -r requirements.txt
-      - name: Run pre-commit
+      - name: Run prek - pre-commit
         id: precommit
-        run: |
-          # Fetch the base branch for comparison
-          git fetch origin ${{ github.base_ref }}
-          uvx pre-commit run --from-ref origin/${{ github.base_ref }} --to-ref HEAD --show-diff-on-failure
+        run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
         continue-on-error: true
       - name: Commit and push changes
         if: env.IS_FORK == 'false'
index 1cff1a5a9becaa1be2e5c6f9920719f0539ca29d..3bbab64a42a5325af80a5982b59cea1b267628ac 100644 (file)
@@ -2,6 +2,6 @@
 -r requirements-tests.txt
 -r requirements-docs.txt
 -r requirements-translations.txt
-pre-commit >=4.5.0,<5.0.0
+prek==0.2.22
 # For generating screenshots
 playwright