Skip to content

Commit

Permalink
Push commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyGibson committed May 14, 2020
1 parent 4188bfd commit 6b237df
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 14 deletions.
7 changes: 3 additions & 4 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
- id: django-migrate
name: django-migrate
name: django migrate
description: Check a django app for missing migrations
entry: hook/django_migrate.sh
language: script
types: [shell]
entry: django-migrate
language: python
always_run: true
verbose: true
10 changes: 0 additions & 10 deletions hook/django_migrate.sh

This file was deleted.

Empty file added hooks/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions hooks/django_migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import subprocess
import os
from pathlib import Path

def main():
exitcode = 0
cp = subprocess.run(
["python", "manage.py", "makemigrations", "--dry-run", "/dev/null"],
capture_output=True
)
if cp.stdout:
if not cp.stdout.__contains__("No changes detected"):
exitcode = 1
return exitcode

if __name__ == "__main__":
exit(main())
26 changes: 26 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[metadata]
name = hooks
version = 0.0.1
description = Checks for missing django migrations
license = MIT
license_file = LICENSE
classifiers =
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy

[options]
packages = find:
python_requires = >=3.6.1

[options.entry_points]
console_scripts =
django-migrate = hooks.django_migrate:main

[bdist_wheel]
universal = True
25 changes: 25 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Always prefer setuptools over distutils
from setuptools import setup
setup()
# from setuptools import setup, find_packages


# setup(
# name='django-migrations',
# version='0.0.1',
# packages=find_packages(),
# entry_points = {
# 'console_scripts': ['django_migrate=django_migrate:check_migrations'],
# },
# url='https://github.com/caktus/django-migrations',
# author='Caktus Group',
# author_email='',
# description='A pre-commit hook to check a django app for migrations',
# python_requires='>=3.5',
# classifiers=[
# 'Intended Audience :: Developers',
# 'Topic :: Software Development :: Build Tools',
# 'License :: OSI Approved :: BSD License',
# 'Programming Language :: Python :: 3',
# ]
# )

0 comments on commit 6b237df

Please sign in to comment.