Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a local pre-commit hook to automatically bump our requirements #27

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ repos:
language: system
always_run: true
pass_filenames: false
- id: bump-precommit-and-identify
name: Bump versions of pre-commit and identify
entry: python bump_identify.py
language: system
always_run: true
pass_filenames: false

- repo: https://github.com/psf/black
rev: 24.4.0
Expand Down Expand Up @@ -57,7 +63,7 @@ repos:
- id: cmake-lint # Apply linting to CMake files

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.3
rev: v18.1.4
hooks:
- id: clang-format # Format C++ code with Clang-Format - automatically applying the changes
types_or: [c++, c, c#, cuda, objective-c]
Expand Down
22 changes: 22 additions & 0 deletions bump_identify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import re
import requests

# Fetch the latest version of the packages
identify_version = requests.get("https://pypi.org/pypi/identify/json").json()["info"][
"version"
]
precommit_version = requests.get("https://pypi.org/pypi/pre-commit/json").json()[
"info"
]["version"]

# Read the content of the pyproject.toml file
with open("pyproject.toml", "r") as f:
data = f.read()

# Replace the version of the packages
data = re.sub(f"identify >=.*\n", f'identify >= {identify_version}",\n', data)
data = re.sub(f"pre-commit >=.*\n", f'pre-commit >= {precommit_version}",\n', data)

# Write the new content to the pyproject.toml file
with open("pyproject.toml", "w") as f:
f.write(data)
8 changes: 7 additions & 1 deletion precommend/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ repos:
language: system
always_run: true
pass_filenames: false
- id: bump-precommit-and-identify
name: Bump versions of pre-commit and identify
entry: python bump_identify.py
language: system
always_run: true
pass_filenames: false

- repo: https://github.com/psf/black
rev: 24.4.0
Expand Down Expand Up @@ -57,7 +63,7 @@ repos:
- id: cmake-lint # Apply linting to CMake files

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.3
rev: v18.1.4
hooks:
- id: clang-format # Format C++ code with Clang-Format - automatically applying the changes
types_or: [c++, c, c#, cuda, objective-c]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ classifiers = [
]
dependencies = [
"click",
"identify >= 2.5.35",
"pre-commit >= 3.6.2",
"identify >= 2.5.36",
"pre-commit >= 3.7.0",
"ruamel.yaml",
]

Expand Down