mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Refs #25604 -- Removed makemigrations --exit option per deprecation timeline.
This commit is contained in:
		| @@ -1,7 +1,6 @@ | ||||
| import io | ||||
| import os | ||||
| import sys | ||||
| import warnings | ||||
| from itertools import takewhile | ||||
|  | ||||
| from django.apps import apps | ||||
| @@ -18,7 +17,6 @@ from django.db.migrations.questioner import ( | ||||
| from django.db.migrations.state import ProjectState | ||||
| from django.db.migrations.utils import get_migration_name_timestamp | ||||
| from django.db.migrations.writer import MigrationWriter | ||||
| from django.utils.deprecation import RemovedInDjango20Warning | ||||
| from django.utils.six import iteritems | ||||
| from django.utils.six.moves import zip | ||||
|  | ||||
| @@ -52,11 +50,6 @@ class Command(BaseCommand): | ||||
|             '-n', '--name', action='store', dest='name', default=None, | ||||
|             help="Use this name for migration file(s).", | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '-e', '--exit', action='store_true', dest='exit_code', default=False, | ||||
|             help='Exit with error code 1 if no changes needing migrations are found. ' | ||||
|                  'Deprecated, use the --check option instead.', | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '--check', action='store_true', dest='check_changes', | ||||
|             help='Exit with a non-zero status if model changes are missing migrations.', | ||||
| @@ -69,15 +62,8 @@ class Command(BaseCommand): | ||||
|         self.merge = options['merge'] | ||||
|         self.empty = options['empty'] | ||||
|         self.migration_name = options['name'] | ||||
|         self.exit_code = options['exit_code'] | ||||
|         check_changes = options['check_changes'] | ||||
|  | ||||
|         if self.exit_code: | ||||
|             warnings.warn( | ||||
|                 "The --exit option is deprecated in favor of the --check option.", | ||||
|                 RemovedInDjango20Warning | ||||
|             ) | ||||
|  | ||||
|         # Make sure the app they asked for exists | ||||
|         app_labels = set(app_labels) | ||||
|         bad_app_labels = set() | ||||
| @@ -186,9 +172,6 @@ class Command(BaseCommand): | ||||
|                     self.stdout.write("No changes detected in apps '%s'" % ("', '".join(app_labels))) | ||||
|                 else: | ||||
|                     self.stdout.write("No changes detected") | ||||
|  | ||||
|             if self.exit_code: | ||||
|                 sys.exit(1) | ||||
|         else: | ||||
|             self.write_migration_files(changes) | ||||
|             if check_changes: | ||||
|   | ||||
| @@ -704,12 +704,6 @@ Enables fixing of migration conflicts. | ||||
|  | ||||
| Allows naming the generated migration(s) instead of using a generated name. | ||||
|  | ||||
| .. django-admin-option:: --exit, -e | ||||
|  | ||||
| .. deprecated:: 1.10 | ||||
|  | ||||
|    Use the ``--check`` option instead. | ||||
|  | ||||
| Makes ``makemigrations`` exit with error code 1 when no migrations are created | ||||
| (or would have been created, if combined with ``--dry-run``). | ||||
|  | ||||
|   | ||||
| @@ -445,7 +445,7 @@ Management Commands | ||||
|   :setting:`FIXTURE_DIRS` contains duplicates or a default fixture directory | ||||
|   path (``app_name/fixtures``), an exception is raised. | ||||
|  | ||||
| * The new :option:`makemigrations --exit` option allows exiting with an error | ||||
| * The new ``makemigrations --exit`` option allows exiting with an error | ||||
|   code if no migrations are created. | ||||
|  | ||||
| * The new :djadmin:`showmigrations` command allows listing all migrations and | ||||
|   | ||||
| @@ -319,3 +319,5 @@ these features. | ||||
| * The ``django.template.loader.LoaderOrigin`` and | ||||
|   ``django.template.base.StringOrigin`` aliases for | ||||
|   ``django.template.base.Origin`` are removed. | ||||
|  | ||||
| * The ``makemigrations --exit`` option is removed. | ||||
|   | ||||
| @@ -17,9 +17,8 @@ from django.db.migrations.exceptions import ( | ||||
|     InconsistentMigrationHistory, MigrationSchemaMissing, | ||||
| ) | ||||
| from django.db.migrations.recorder import MigrationRecorder | ||||
| from django.test import ignore_warnings, mock, override_settings | ||||
| from django.test import mock, override_settings | ||||
| from django.utils import six | ||||
| from django.utils.deprecation import RemovedInDjango20Warning | ||||
| from django.utils.encoding import force_text | ||||
|  | ||||
| from .models import UnicodeModel, UnserializableModel | ||||
| @@ -1232,19 +1231,6 @@ class MakeMigrationsTests(MigrationTestBase): | ||||
|             self.assertIn("dependencies=[\n('migrations','0001_%s'),\n]" % migration_name_0001, content) | ||||
|             self.assertIn("operations=[\n]", content) | ||||
|  | ||||
|     @ignore_warnings(category=RemovedInDjango20Warning) | ||||
|     def test_makemigrations_exit(self): | ||||
|         """ | ||||
|         makemigrations --exit should exit with sys.exit(1) when there are no | ||||
|         changes to an app. | ||||
|         """ | ||||
|         with self.temporary_migration_module(): | ||||
|             call_command("makemigrations", "--exit", "migrations", verbosity=0) | ||||
|  | ||||
|         with self.temporary_migration_module(module="migrations.test_migrations_no_changes"): | ||||
|             with self.assertRaises(SystemExit): | ||||
|                 call_command("makemigrations", "--exit", "migrations", verbosity=0) | ||||
|  | ||||
|     def test_makemigrations_check(self): | ||||
|         """ | ||||
|         makemigrations --check should exit with a non-zero status when | ||||
|   | ||||
		Reference in New Issue
	
	Block a user