David Wobrock
31338714dd
Fix #112 -- make the behaviour of --include-migrations-from more obvious
...
* Misspelled filename => fail (instead of linting all migrations and ignoring the error)
* An empty file/a file with no valid migration paths => lint no migrations (instead oflinting all migrations)
* If the option is not specified, keep the behaviour of linting all migrations
2020-06-17 22:32:42 +02:00
Gerhard Kotze
50bbed4a1a
Keep line under 88 characters
2020-05-16 21:14:12 +02:00
Gerhard Kotze
56d5f8c26c
Handle get_model calls with linebreaks before and after arguments
...
For example code formatted with `black` could look something like this and is not picked up by the existing regex
FreakishlyLongerThanUsualModel = get_model(
'longerthanusualapp', 'FreakishlyLongerThanUsualModel'
)
2020-05-16 21:14:12 +02:00
David Wobrock
c048bdf745
Simplify print statements
2020-03-13 23:24:39 +01:00
Vladyslav Krylasov
e01f294d4f
Fix a linting error
2020-03-13 23:12:07 +01:00
Vladyslav Krylasov
7b14fd5292
Make an output of print_summary more readable
2020-03-13 23:12:07 +01:00
David Wobrock
cb6961539c
Handle for forward and backward data migration imports
2020-02-08 22:38:05 +01:00
David Wobrock
19023626e6
Introduce a first PY2/PY3 difference for inspect.get(full)argspec call
2020-02-07 23:29:15 +01:00
David Wobrock
a0e7ca099b
Simplify passing migration object directly into analysing data migration
2020-02-07 23:29:15 +01:00
David Wobrock
9f22116541
Black the code
2020-02-07 23:29:15 +01:00
David Wobrock
2e7eec42c2
Remove the 'warn' in front of warning messages
2020-02-07 23:29:15 +01:00
David Wobrock
a0d5e2940c
Import RunPython directly to avoid shadowing existing names
2020-02-07 23:29:15 +01:00
David Wobrock
1925343f4a
Move constants to specific file and remove unused import
2020-02-07 23:29:15 +01:00
David Wobrock
e49f6dea9c
Document, add to changelog the data migrations and rename to 'warnings-as-errors' (plural)
2020-02-07 23:29:15 +01:00
David Wobrock
71614bd377
Handle warning as error and exclude warning tests
2020-02-07 23:29:15 +01:00
David Wobrock
d01875b3be
add warnings and RunPython basic linting
2020-02-07 23:29:15 +01:00
David Wobrock
d410d2c7ba
Refactor some linting code to more intelligible conditions
2020-02-07 23:29:15 +01:00
David Wobrock
813c5c8690
Remove apache license headers in each file. The one full copy of the license at the root of the repo shall define the license for all source files.
2020-01-11 22:08:33 +01:00
David Wobrock
ceabb40a62
Change migration linting prints to use conditined methods
2019-10-21 22:25:52 +02:00
David Wobrock
3b8e86fdf7
Add 'quiet' to argparsing and pass it to the linter
2019-10-21 22:25:52 +02:00
David Wobrock
72f066e710
Add MessageType enum for differentiating messages
2019-10-21 22:25:52 +02:00
David Wobrock
e6e8cc7525
Update migrations list file behaviour
...
Instead of using the file path when the git commit is not
added, use the file and the migrations list no matter if we select
all migrations or just from a certain git commit.
And unit tests :)
2019-10-12 15:53:18 +02:00
yongming
dbebda65d9
Fix help in command line, fix read file
2019-10-10 22:50:17 +02:00
yongming
adf61dd669
Add command to only check migration files in a given file
2019-10-10 22:50:17 +02:00
David Wobrock
5c5507a4c3
Also catch specific mysql errors during sqlmigrate
2019-07-30 10:47:20 +02:00
David Wobrock
a74a7497ad
Catch exception if sqlmigrate fails
...
Because of missing constraint that Django cannot find and therefore drop.
2019-07-30 10:47:20 +02:00
David Wobrock
ef2052a7b0
Work on SQL Analyser module
...
* With database specific functions
* Functions that analyse the entire transaction
* Unit tests that only test this module
2019-07-29 21:05:12 +02:00
David Wobrock
85b9abdbc3
Display information that a problem has been found but ignored (and therefore the migration is considered ok)
2019-07-28 12:28:56 +02:00
David Wobrock
af4b11c563
Document (README & CHANGELOG) and rename option to 'exclude-migration-tests'
2019-07-28 12:28:56 +02:00
Vladyslav Malynych
8eede82a38
Exclude not critical test ( #2 )
...
* Exclude not critical test
* Add exclude-tests option
* Update documentation
* Clean forgotten print
* Improve Readme, with examples
2019-07-28 12:28:56 +02:00
David Wobrock
19fe5b75fe
Add logic to ignore applied or unapplied migrations
2019-06-06 22:54:08 +02:00
David Wobrock
ba0704ef3a
Always load migrations from database:
...
This enables us to detect if a migration has been applied to a certain database.
No matter if the migrations and detected from git or all, we always match them with the migrations found by Django.
2019-06-06 22:54:08 +02:00
David Wobrock
3273f1bdc4
Add exclusive options for linting only applied or unapplied migrations
2019-06-06 22:54:08 +02:00
Tobias Kroenke
48cba37764
remove migration ignore sql analysis
2019-05-19 22:29:02 +02:00
Tobias Krönke
12d0b7e9be
obey max line length
2019-05-19 22:29:02 +02:00
Tobias Krönke
44a0c83897
simplify any statement
2019-05-19 22:29:02 +02:00
Tobias Krönke
859b4b3b1b
fix tests
2019-05-19 22:29:02 +02:00
Tobias Krönke
3f5b7bdb9b
make should_ignore_migration check for IgnoreMigration operation
2019-05-19 22:29:02 +02:00
Felix
08dc26085b
First check ignores then check cache
...
This gives you the possibility to add a errornous migration
to the ignore list. On the seccond run the linter will
first use the ignore list and not the cache first.
2019-05-12 15:32:57 +02:00
David Wobrock
484a775fda
Linter Core: change lots of behaviour
...
* Use the Django migration classes to manipulate these objects
this includes the discovery of migrations through the MigrationLoader
(instead of manually walking through the Django project and find the migrations through a regex)
and representing a Migration through the Django class.
* Get the SQL of a migration through a 'call_command' call of 'sqlmigrate'
That speeds up greatly the linter since we don't have to setup Django for each migration
* Add the database to the cache path
2019-05-12 15:32:57 +02:00
Taras Vozniuk
fb0d7f07bc
quite migration name to avoid failures of migration with space in the name
2019-04-21 12:47:17 +02:00
David-Wobrock
36e7dfaa0e
Do not create cache folder if no-cache option
2019-02-24 18:18:45 +01:00
David-Wobrock
999ee2fa5e
unrelated: fix some warnings and redundant elements
2019-02-24 15:55:05 +01:00
David-Wobrock
f8d9ab777a
Do not manually retrieve python interpreter path
...
Instead of doing custom and wrong path detection, just
use sys.executable which does exactly that
2019-02-24 11:04:21 +01:00
David Wobrock
fea623630e
Add --version option
2019-02-03 19:38:38 +01:00
David Wobrock
009153fbf4
handle linting a project in pwd
...
When calling "django-migration-linter ."
be able to handle it (especially with cache)
2019-01-20 12:17:11 +01:00
David Wobrock
75c969c6a9
Revert "don't assume git root is django_path"
...
This reverts commit c14f9aef37 .
2019-01-20 11:46:30 +01:00
Dat Hoang
dca50b3afb
Make sure file paths from git diff are relative to django_path instead of git repos root path
...
Currently, the git diff command return file paths which are relative to git repos root path, which will cause invalid migration file path if git repos root path is different from django_path
2019-01-20 11:43:33 +01:00
Victor Seva
c14f9aef37
don't assume git root is django_path
...
> DJANGO_SETTINGS_MODULE=xpbx.test django-migration-linter --no-cache $(pwd)/xpbx origin/2.4.1
> (customers, 0010_auto_20181026_1330)... Traceback (most recent call last):
> File "/home/vseva/Env/xpbx/bin/django-migration-linter", line 11, in <module>
> sys.exit(_main())
> File "/home/vseva/Env/xpbx/lib/python3.6/site-packages/django_migration_linter/migration_linter.py", line 341, in _main
> linter.lint_all_migrations(git_commit_id=args.commit_id)
> File "/home/vseva/Env/xpbx/lib/python3.6/site-packages/django_migration_linter/migration_linter.py", line 145, in lint_all_migrations
> self.lint_migration(m)
> File "/home/vseva/Env/xpbx/lib/python3.6/site-packages/django_migration_linter/migration_linter.py", line 81, in lint_migration
> md5hash = self.old_cache.md5(migration.abs_path)
> File "/home/vseva/Env/xpbx/lib/python3.6/site-packages/django_migration_linter/cache.py", line 47, in md5
> with open(path, "rb") as f:
> FileNotFoundError: [Errno 2] No such file or directory: '/home/vseva/Foehn/xpbx/xpbx/xpbx/customers/migrations/0010_auto_20181026_1330.py'
Fix : #37
2019-01-17 20:40:32 +01:00
Felix
ab5536c8e7
Remove is_git_project from import
2019-01-07 12:25:57 +01:00