Full Code of pre-commit/action for AI

main 1b06ec171f2f cached
5 files
4.8 KB
1.4k tokens
1 requests
Download .txt
Repository: pre-commit/action
Branch: main
Commit: 1b06ec171f2f
Files: 5
Total size: 4.8 KB

Directory structure:
gitextract_k2du2id7/

├── .github/
│   └── workflows/
│       └── main.yml
├── .pre-commit-config.yaml
├── LICENSE
├── README.md
└── action.yml

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/workflows/main.yml
================================================
on:
  pull_request:
  push:
    branches: [main, test-me-*]

jobs:
  main:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-python@v3
    - name: self test action
      uses: ./


================================================
FILE: .pre-commit-config.yaml
================================================
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml


================================================
FILE: LICENSE
================================================
Copyright (c) 2019 Anthony Sottile

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


================================================
FILE: README.md
================================================
this action is in maintenance-only mode and will not be accepting new features.

generally you want to use [pre-commit.ci] which is faster and has more features.

[pre-commit.ci]: https://pre-commit.ci

___

[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pre-commit/action/main.svg)](https://results.pre-commit.ci/latest/github/pre-commit/action/main)
[![Build Status](https://github.com/pre-commit/action/actions/workflows/main.yml/badge.svg)](https://github.com/pre-commit/action/actions)

pre-commit/action
=================

a GitHub action to run [pre-commit](https://pre-commit.com)

### using this action

To use this action, make a file `.github/workflows/pre-commit.yml`.  Here's a
template to get started:

```yaml
name: pre-commit

on:
  pull_request:
  push:
    branches: [main]

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-python@v3
    - uses: pre-commit/action@v3.0.1
```

This does a few things:

- clones the code
- installs python
- sets up the `pre-commit` cache

### using this action with custom invocations

By default, this action runs all the hooks against all the files.  `extra_args`
lets users specify a single hook id and/or options to pass to `pre-commit run`.

Here's a sample step configuration that only runs the `flake8` hook against all
the files (use the template above except for the `pre-commit` action):

```yaml
    - uses: pre-commit/action@v3.0.1
      with:
        extra_args: flake8 --all-files
```

### using this action in private repositories

prior to v3.0.0, this action had custom behaviour which pushed changes back to
the pull request when supplied with a `token`.

this behaviour was removed:
- it required a PAT (didn't work with short-lived `GITHUB_TOKEN`)
- properly hiding this `input` from the installation and execution of hooks
  is intractable in github actions (it is readily available as `$INPUT_TOKEN`)
- this meant potentially unvetted code could access the token via the
  environment

you can _likely_ achieve the same thing with an external action such as
[git-auto-commit-action] though you may want to take precautions to clear `git`
hooks or other ways that arbitrary code execution can occur when running
`git commit` / `git push` (for example [core.fsmonitor]).

while unrelated to this action, [pre-commit.ci] avoids these problems by
installing and executing isolated from the short-lived repository-scoped
[installation access token].

[git-auto-commit-action]: https://github.com/stefanzweifel/git-auto-commit-action
[core.fsmonitor]: https://github.blog/2022-04-12-git-security-vulnerability-announced/
[pre-commit.ci]: https://pre-commit.ci
[installation access token]: https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app


================================================
FILE: action.yml
================================================
name: pre-commit
description: run pre-commit
inputs:
  extra_args:
    description: options to pass to pre-commit run
    required: false
    default: '--all-files'
runs:
  using: composite
  steps:
  - run: python -m pip install pre-commit
    shell: bash
  - run: python -m pip freeze --local
    shell: bash
  - uses: actions/cache@v4
    with:
      path: ~/.cache/pre-commit
      key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
  - run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
    shell: bash
Download .txt
gitextract_k2du2id7/

├── .github/
│   └── workflows/
│       └── main.yml
├── .pre-commit-config.yaml
├── LICENSE
├── README.md
└── action.yml
Condensed preview — 5 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (5K chars).
[
  {
    "path": ".github/workflows/main.yml",
    "chars": 225,
    "preview": "on:\n  pull_request:\n  push:\n    branches: [main, test-me-*]\n\njobs:\n  main:\n    runs-on: ubuntu-latest\n    steps:\n    - u"
  },
  {
    "path": ".pre-commit-config.yaml",
    "chars": 176,
    "preview": "repos:\n-   repo: https://github.com/pre-commit/pre-commit-hooks\n    rev: v6.0.0\n    hooks:\n    -   id: trailing-whitespa"
  },
  {
    "path": "LICENSE",
    "chars": 1059,
    "preview": "Copyright (c) 2019 Anthony Sottile\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this"
  },
  {
    "path": "README.md",
    "chars": 2832,
    "preview": "this action is in maintenance-only mode and will not be accepting new features.\n\ngenerally you want to use [pre-commit.c"
  },
  {
    "path": "action.yml",
    "chars": 577,
    "preview": "name: pre-commit\ndescription: run pre-commit\ninputs:\n  extra_args:\n    description: options to pass to pre-commit run\n  "
  }
]

About this extraction

This page contains the full source code of the pre-commit/action GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 5 files (4.8 KB), approximately 1.4k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!