diff --git a/django_migration_linter/management/commands/lintmigrations.py b/django_migration_linter/management/commands/lintmigrations.py index 1100dfb..6720f18 100644 --- a/django_migration_linter/management/commands/lintmigrations.py +++ b/django_migration_linter/management/commands/lintmigrations.py @@ -25,15 +25,6 @@ class Command(BaseCommand): "the initial repo commit will be used" ), ) - parser.add_argument( - "--include-migrations-in-file", - metavar="FILE_PATH", - type=str, - nargs="?", - help=( - "if specified, only migrations inside the file " "will be considered", - ), - ) parser.add_argument( "--ignore-name-contains", type=str, @@ -58,7 +49,13 @@ class Command(BaseCommand): parser.add_argument( "--project-root-path", type=str, nargs="?", help="django project root path" ) - + parser.add_argument( + "--include-migrations-from", + metavar="FILE_PATH", + type=str, + nargs="?", + help="if specified, only migrations listed in the file will be considered", + ) cache_group = parser.add_mutually_exclusive_group(required=False) cache_group.add_argument( "--cache-path", @@ -133,7 +130,7 @@ class Command(BaseCommand): ) linter.lint_all_migrations( git_commit_id=options["commit_id"], - migrations_file_path=options["include_migrations_in_file"], + migrations_file_path=options["include_migrations_from"], ) linter.print_summary() if linter.has_errors: diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index 2d333ca..3f9cf34 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -256,8 +256,10 @@ class MigrationLinter(object): migrations = [] with open(migrations_file_path, "r") as f: - lines = f.read() - for line in lines: + for line in f: + if not line: + continue + if ( re.search(r"/{0}/.*\.py".format(MIGRATIONS_MODULE_NAME), line) and "__init__" not in line