{"id":21168413,"url":"https://github.com/anaconda/pre-commit-hooks","last_synced_at":"2025-12-30T12:42:26.349Z","repository":{"id":37104652,"uuid":"473282153","full_name":"anaconda/pre-commit-hooks","owner":"anaconda","description":"Pre-commit hooks used for Anaconda projects","archived":false,"fork":false,"pushed_at":"2024-05-19T14:00:19.000Z","size":116,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":25,"default_branch":"main","last_synced_at":"2024-05-19T14:51:35.476Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anaconda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-23T17:02:28.000Z","updated_at":"2024-06-02T14:25:01.434Z","dependencies_parsed_at":"2023-02-12T08:00:49.192Z","dependency_job_id":"bbadda02-11ae-41a2-b0ac-82ba4ce457fb","html_url":"https://github.com/anaconda/pre-commit-hooks","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anaconda%2Fpre-commit-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anaconda%2Fpre-commit-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anaconda%2Fpre-commit-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anaconda%2Fpre-commit-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anaconda","download_url":"https://codeload.github.com/anaconda/pre-commit-hooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243615629,"owners_count":20319733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T15:12:55.986Z","updated_at":"2025-12-30T12:42:26.301Z","avatar_url":"https://github.com/anaconda.png","language":"Python","readme":"# Anaconda pre-commit hooks\n\nThis repo contains custom `pre-commit` hooks.\n\n## generate-renovate-annotations\n\nThe `generate-renovate-annotations` hook is used to add Renovate comments to conda environment files.\nThe format of these comments is prescribed with a RegEx rule, with more details in the [.documentation](https://github.com/anaconda/renovate-config/blob/main/docs/conda-environment.md)\n\nBy default, this hook will work for all files matching the `environment.*\\.ya?ml` regular expression.\nThis matches common formats like `environment.yaml`, `environment.yml`, and `environment-suffix.yml`.\n\nTo pull pip packages from an alternate index, each package must be specified with the `--internal-pip-package` option (multiple allowed).\nThe index URL is specified with the `--internal-pip-index-url` option.\n\n\u003e **Note:** The Renovate worker must be configured with adequate credentials if this URL requires authentication.\n\nAn example usage is shown below:\n\n```yaml\n- repo: https://github.com/anaconda/pre-commit-hooks\n  rev: main  # Use the ref you want to point at\n  hooks:\n    - id: generate-renovate-annotations\n      args: [\n      --internal-pip-index-url=https://pypi.anaconda.org/my-organization/simple,\n      --internal-pip-package=my-private-package,\n      --internal-pip-package=my-other-private-package,\n      --create-command=\"make setup\",     # Default value\n      --environment-selector=\"-p ./env\", # Default value\n      --disable-environment-creation     # Creation enabled by default\n    ]\n```\n\nThe hook is backed by a CLI command, whose help output is reproduced below:\n\n\u003c!-- [[[cog\n#import os, sys; sys.path.insert(0, os.path.join(os.getcwd(), \"dev\"))\n#from generate_cli_output import main\n#main(command=\"generate-renovate-annotations --help\")\n]]] --\u003e\n\u003c!-- [[[end]]] --\u003e\n```shell\nUsage: generate-renovate-annotations [OPTIONS] ENV_FILES... COMMAND [ARGS]...\n\n Generate Renovate comments for a list of conda environment files.\n For each file, we:\n\n  • Run a command to ensure the environment is created/updated\n  • Extract a list of installed packages in that environment, including pip\n  • Generate a Renovate annotation comment, including the package name and\n    channel. This step also allows for overriding the index of pip packages.\n  • Pin the exact installed version of each dependency.\n\n╭─ Arguments ──────────────────────────────────────────────────────────────────╮\n│ *    env_files      ENV_FILES...  A list of conda environment files,         │\n│                                   typically passed in from pre-commit        │\n│                                   automatically                              │\n│                                   [default: None]                            │\n│                                   [required]                                 │\n╰──────────────────────────────────────────────────────────────────────────────╯\n╭─ Options ────────────────────────────────────────────────────────────────────╮\n│ --internal-pip-package                TEXT  One or more packages to pull     │\n│                                             from the                         │\n│                                             --internal-pip-index-url         │\n│                                             [default: None]                  │\n│ --internal-pip-index-url              TEXT  An optional extra pip index URL, │\n│                                             used in conjunction with the     │\n│                                             --internal-pip-package option    │\n│ --create-command                      TEXT  A command to invoke at each      │\n│                                             parent directory of all          │\n│                                             environment files to ensure the  │\n│                                             conda environment is created and │\n│                                             updated                          │\n│                                             [default: make setup]            │\n│ --environment-selector                TEXT  A string used to select the      │\n│                                             conda environment, either        │\n│                                             prefix-based (recommended) or    │\n│                                             named                            │\n│                                             [default: -p ./env]              │\n│ --disable-environment-creation              If set, environment will not be  │\n│                                             created/updated before           │\n│                                             annotations are added.           │\n│ --help                                      Show this message and exit.      │\n╰──────────────────────────────────────────────────────────────────────────────╯\n```\n\n## run-cog\n\nThe `run-cog` hook can be used to run the [`cog`](https://nedbatchelder.com/code/cog) tool automatically to generate code when committing a file.\nOne common example is to generate command-line output in a README file.\n\nThe example below will run `cog` on all text-like files, ensuring the working directory is set to the directory in which the file is located.\nThis is particularly useful if the `cog` script itself uses `subprocess` to execute command-line applications.\n\n```yaml\n-   repo: https://github.com/anaconda/pre-commit-hooks\n    rev: main  # Use the ref you want to point at\n    hooks:\n    -   id: run-cog\n        args: [\"--working-directory-level\", \"-1\"]\n```\n## mjml-hook\n\nA simple wrapper around the [`mjml`](https://github.com/mjmlio/mjml) tool to use as a [`pre-commit`](https://pre-commit.com) hook.\n\n### Using mjml-hook with pre-commit\n\nAdd this to your `.pre-commit-config.yaml`\n\n```yaml\n-   repo: https://github.com/mattkram/mjml-hook\n    rev: main  # Use the ref you want to point at\n    hooks:\n    -   id: mjml\n```\n\n### What does the hook do?\n\nThe pre-commit hook will execute any time a file with the pattern `*.mjml` is staged for commit.\nFor each of these files, the following command is run:\n\n```shell\nmjml \u003cfilename\u003e.mjml -o \u003cfilename\u003e.html\n```\n\nwhere the base filename remains the same, and the extension is changed.\n\nIf the HTML file is already being tracked by `git` and is changed by the hook, `pre-commit` will raise an error.\nIf this is a new template, `pre-commit` will not fail and you may need to do an amend commit to add the initial HTML file to the `git` history.\n\n```shell\ngit commit --amend path/to/file.html\n```\n\n## Dev setup\n\nWe have a dev setup that uses `conda` for environment management.\nWe also use `make` to automate common tasks.\nThe targets are documented below:\n\n\n\u003c!-- [[[cog\nimport os, sys; sys.path.insert(0, os.path.join(os.getcwd(), \"dev\"))\nfrom generate_makefile_targets_table import main; main()\n]]] --\u003e\n\u003c!-- THE FOLLOWING CODE IS GENERATED BY COG VIA PRE-COMMIT. ANY MANUAL CHANGES WILL BE LOST. --\u003e\n| Target          | Description                                                              |\n|-----------------|--------------------------------------------------------------------------|\n| `help`          | Display help on all Makefile targets                                     |\n| `setup`         | Setup local conda environment for development                            |\n| `install-hooks` | Download + install all pre-commit hooks                                  |\n| `pre-commit`    | Run pre-commit against all files                                         |\n| `type-check`    | Run static type checks                                                   |\n| `test`          | Run all the unit tests                                                   |\n| `cog-readme`    | Run cog on the README.md to generate command output                      |\n\u003c!-- [[[end]]] --\u003e\n\n\u003e **Note:** Interestingly, the table above is generated by the `cog` hook defined in this repo :smile:\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanaconda%2Fpre-commit-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanaconda%2Fpre-commit-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanaconda%2Fpre-commit-hooks/lists"}