Skip to content

Commit a785b8e

Browse files
committed
Add HISTORY_TRUNCATE_HASH setting
1 parent d1c69a0 commit a785b8e

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ jobs:
3737
- 5432:5432
3838
strategy:
3939
matrix:
40-
django-version: [3.2, 4.2]
41-
python-version: [3.8, 3.9, 3.11]
40+
django-version: ["4.2", "5.2"]
41+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
4242
steps:
4343
- uses: actions/checkout@v2
4444
- name: Set up Python ${{ matrix.python-version }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ __pycache__
77
build
88
dist
99
.vscode
10+
.nova
11+
.coverage

history/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version_info__ = (2, 0, 2)
1+
__version_info__ = (2, 1, 0)
22
__version__ = ".".join(str(i) for i in __version_info__)
33

44
default_app_config = "history.apps.HistoryConfig"

history/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
USER_TYPE = getattr(settings, "HISTORY_USER_TYPE", "integer")
77
DEFAULT_USER = getattr(settings, "HISTORY_DEFAULT_USER", 0)
88
DEFAULT_USER_ERROR = getattr(settings, "HISTORY_DEFAULT_USER_ERROR", False)
9+
TRUNCATE_HASH = getattr(settings, "HISTORY_TRUNCATE_HASH", "md5")
910

1011
# The database role that should own the history tables and triggers.
1112
DB_ROLE = getattr(settings, "HISTORY_DB_ROLE", settings.DATABASES["default"]["USER"])

history/management/commands/triggers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def truncate_long_name(name):
1212
# 63 characters. Originally found in django/db/backends/utils.py in "truncate_name"
1313
# Django source code:
1414
# https://github.com/django/django/blob/stable/1.5.x/django/db/backends/util.py#L133
15-
hsh = hashlib.md5(force_bytes(name)).hexdigest()[:5]
15+
hsh = getattr(hashlib, conf.TRUNCATE_HASH)(force_bytes(name)).hexdigest()[:5]
1616
return "%s_%s" % (name[:57], hsh) if len(name) > 63 else name
1717

1818

0 commit comments

Comments
 (0)