Modified the django patch check action from [14474] (for django issue #28772) to work with arbitrary locations of the virtual Python environment, rather than assuming a particular location of the virtual environment directory.
- Legacy-Id: 14487
Note: SVN reference [14474] has been migrated to Git commit bb92c0a076
This commit is contained in:
parent
4695ec5383
commit
11ca8dcaf2
|
@ -351,10 +351,21 @@ def check_svn_import(app_configs, **kwargs):
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
@checks.register('files')
|
@checks.register('files')
|
||||||
def maybe_patch_django_db_model_fields_unicode_comparison(app_configs, **kwargs):
|
def maybe_patch_django(app_configs, **kwargs):
|
||||||
errors = []
|
errors = []
|
||||||
for patch_file in settings.CHECKS_PATCHES_TO_APPLY:
|
# Change path to our copy of django (this assumes we're running in a
|
||||||
patch_set = patch.fromfile(patch_file)
|
# virtualenv, which we should)
|
||||||
|
import os, django
|
||||||
|
django_path = os.path.dirname(django.__file__)
|
||||||
|
parent_path = os.path.dirname(django_path)
|
||||||
|
saved_cwd = os.getcwd()
|
||||||
|
os.chdir(parent_path)
|
||||||
|
# All patches in settings.CHECKS_DJANGO_PATCHES_TO_APPLY must have a
|
||||||
|
# relative file path rooted in the django dir, for instance
|
||||||
|
# 'django/db/models/fields/__init__.py'
|
||||||
|
for patch_file in settings.CHECKS_DJANGO_PATCHES_TO_APPLY:
|
||||||
|
patch_path = os.path.join(saved_cwd, patch_file)
|
||||||
|
patch_set = patch.fromfile(patch_path)
|
||||||
if patch_set:
|
if patch_set:
|
||||||
if not patch_set.apply():
|
if not patch_set.apply():
|
||||||
errors.append(checks.Warning(
|
errors.append(checks.Warning(
|
||||||
|
@ -368,6 +379,7 @@ def maybe_patch_django_db_model_fields_unicode_comparison(app_configs, **kwargs)
|
||||||
hint="Make sure that the patch file contains a unified diff",
|
hint="Make sure that the patch file contains a unified diff",
|
||||||
id="datatracker.W0001",
|
id="datatracker.W0001",
|
||||||
))
|
))
|
||||||
|
os.chdir(saved_cwd)
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
@checks.register('security')
|
@checks.register('security')
|
||||||
|
|
|
@ -927,7 +927,7 @@ SILENCED_SYSTEM_CHECKS = [
|
||||||
"fields.W342", # Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
|
"fields.W342", # Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
|
||||||
]
|
]
|
||||||
|
|
||||||
CHECKS_PATCHES_TO_APPLY = [
|
CHECKS_DJANGO_PATCHES_TO_APPLY = [
|
||||||
'patch/fix-django-unicode-comparison-bug.patch',
|
'patch/fix-django-unicode-comparison-bug.patch',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ./../yang/env/lib/python2.7/site-packages/django/db/models/fields/__init__.py 2017-06-14 08:43:21.665812000 -0700
|
--- django/db/models/fields/__init__.py.old 2017-06-14 08:43:21.665812000 -0700
|
||||||
+++ env/lib/python2.7/site-packages/django/db/models/fields/__init__.py 2017-12-17 14:34:03.023976702 -0800
|
+++ django/db/models/fields/__init__.py 2017-12-17 14:34:03.023976702 -0800
|
||||||
@@ -2323,7 +2323,7 @@
|
@@ -2323,7 +2323,7 @@
|
||||||
if self.has_default() and not callable(self.default):
|
if self.has_default() and not callable(self.default):
|
||||||
return self.default
|
return self.default
|
||||||
|
|
Loading…
Reference in a new issue