Skip to content

Commit

Permalink
Merge pull request #27 from ssciwr/autobump
Browse files Browse the repository at this point in the history
Add a local pre-commit hook to automatically bump our requirements
  • Loading branch information
dokempf authored Apr 23, 2024
2 parents 16d02f6 + bc8c0bc commit 8839484
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
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

0 comments on commit 8839484

Please sign in to comment.