Skip to content
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: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
with:
fetch-depth: 0

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
cache: "pip"
cache-dependency-path: "**/pyproject.toml"

Expand All @@ -27,7 +27,7 @@ jobs:
- name: 🏗️ Build
run: python -m flit build

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: ./dist

Expand All @@ -42,7 +42,7 @@ jobs:
# Mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4

- name: 🚀 Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- run: python -Im pip install --user ruff
# Keep in sync with .pre-commit-config.yaml
- run: python -Im pip install --user ruff==0.8.0

- name: Run ruff
working-directory: ./src
run: ruff --output-format=github wagtail_localize_git
run: ruff check --output-format=github wagtail_localize_git
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ env:
TOX_TESTENV_PASSENV: FORCE_COLOR
PIP_DISABLE_PIP_VERSION_CHECK: '1'
PIP_NO_PYTHON_VERSION_WARNING: '1'
PYTHON_LATEST: '3.11'
PYTHON_LATEST: '3.12'

jobs:
test-sqlite:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
db: ["sqlite"]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -56,14 +56,15 @@ jobs:
name: coverage-data
path: .coverage.*
if-no-files-found: ignore
include-hidden-files: true
retention-days: 1

test-postgres:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
db: ["sqlite"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
db: ["postgres"]

services:
postgres:
Expand Down Expand Up @@ -100,6 +101,7 @@ jobs:
name: coverage-data
path: .coverage.*
if-no-files-found: ignore
include-hidden-files: true
retention-days: 1

coverage:
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ ci:
autofix_prs: false

default_language_version:
python: python3.11
python: python3.13

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -19,7 +19,8 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.13'
# keep in sync with .github/workflows/ruff.yml
rev: 'v0.8.0'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
16 changes: 9 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Framework :: Wagtail",
"Framework :: Wagtail :: 5",
"Framework :: Wagtail :: 6",
]

dynamic = ["version"]
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = [
"Django>=3.2,<5.1",
"Wagtail>=4.1",
"Django>=4.2,<5.2",
"Wagtail>=5.2",
"wagtail-localize>=1.0",
"pygit2>=1.0,<2.0",
"gitpython>=3.0,<4.0",
Expand Down Expand Up @@ -69,8 +70,9 @@ exclude = [
]

[tool.ruff]
target-version = "py38"
target-version = "py39"

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
Expand All @@ -90,7 +92,7 @@ select = [
ignore = ["E501"]
fixable = ["C4", "E", "F", "I", "UP"]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["src", "wagtail_localize_git"]
lines-between-types = 1
lines-after-imports = 2
14 changes: 12 additions & 2 deletions src/wagtail_localize_git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ def get_changed_files(self, old_commit, new_commit):

def get_head_commit_id(self):
if not self.repo_is_empty:
return self.pygit.head.target.hex
try:
return self.pygit.head.target.hex
except AttributeError:
# see https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md#1150-2024-05-18
# remove after dropping libgit2 < 1.15
return str(self.pygit.head.target)


class RepositoryReader:
Expand Down Expand Up @@ -191,4 +196,9 @@ def commit(self, message):
[self.repo.head.target],
)

return self.repo.head.target.hex
try:
return self.repo.head.target.hex
except AttributeError:
# see https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md#1150-2024-05-18
# remove after dropping libgit2 < 1.15
return str(self.repo.head.target)
7 changes: 6 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ def make_commit_from_index(self, repo, index, message):
[repo.pygit.head.target],
)

return repo.pygit.head.target.hex
try:
return repo.pygit.head.target.hex
except AttributeError:
# see https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md#1150-2024-05-18
# remove after dropping libgit2 < 1.15
return str(repo.pygit.head.target)

def assert_file_in_tree(self, tree, name, mode=33188, check_contents=None):
blobs_by_name = {blob.name: blob for blob in tree.blobs}
Expand Down
18 changes: 9 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
[tox]
min_version = 4.0
min_version = 4.23

envlist =
py{3.8,3.9,3.10}-django{3.2}-wagtail{4.1, 5.2}
py{3.8,3.9,3.10,3.11,3.12}-django{4.2}-wagtail{5.2}
py{3.10,3.11,3.12}-django{5.0}-wagtail{5.2}
py{3.9,3.10,3.11,3.12}-django{4.2,5.0}-wagtail{5.2,6.2,6.3}
py{3.11,3.12,3.13}-django{5.1}-wagtail{6.3}

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313

[gh-actions:env]
DB =
Expand All @@ -34,13 +33,14 @@ setenv =
deps =
flit>=3.8

django3.2: Django>=3.2,<3.3
django4.2: Django>=4.2,<4.3
django5.0: Django>=5.0,<5.1
django5.0: Django>=5.0,<5.
django5.1: Django>=5.1,<5.2
djmain: git+https://github.com/django/django.git@main#egg=Django

wagtail4.1: wagtail>=4.1,<4.2
wagtail5.2: wagtail>=5.2,<5.3
wagtail6.2: wagtail>=6.2,<6.3
wagtail6.3: wagtail>=6.3,<6.4
wagtailmain: git+https://github.com/wagtail/wagtail.git

postgres: psycopg2>=2.9
Expand All @@ -60,7 +60,7 @@ commands =

[testenv:interactive]
description = An interactive environment for local testing purposes
basepython = python3.11
basepython = python3.12

commands_pre =
python {toxinidir}/tests/manage.py makemigrations
Expand Down