Merge branch 'dev'

This commit is contained in:
David-Wobrock committed 2018-01-20 16:19:32 +01:00
commit 416a102186
97 files changed
+735 -583

No files matched your search

-61
View File
@@ -1,61 +0,0 @@
# Django migration linter
> Detect backward incompatible migrations for your django project. It will save you time by making sure migrations will not break anything.
<a href="https://travis-ci.org/3YOURMIND/django-migration-linter"><img src="https://travis-ci.org/3YOURMIND/django-migration-linter.svg?branch=master" alt="badge of travis CI" /></a>
<a href="https://pypi.python.org/pypi/django-migration-linter/"><img src="https://img.shields.io/pypi/v/django-migration-linter.svg" alt="PyPi version" /></a>
<a href="./LICENSE"><img src="https://img.shields.io/github/license/3yourmind/django-migration-linter.svg" alt="badge of license" /></a>
<a href="https://github.com/3YOURMIND/django-migration-linter/pulls"><img src="https://img.shields.io/badge/PR-welcome-green.svg" alt="badge of pull request welcome" /></a>
<a href="https://www.3yourmind.com/career"><img src="https://img.shields.io/badge/3YOURMIND-Hiring-brightgreen.svg" alt="badge of hiring advertisement of 3yourmind" /></a>
<a href="https://github.com/3YOURMIND/django-migration-linter/stargazers"><img src="https://img.shields.io/github/stars/3YOURMIND/django-migration-linter.svg?style=social&label=Stars" alt="badge of github star" /></a>
## Dependencies
<p><details>
<summary><b>Needed software (in PATH)</b></summary>
* `python`
* `git` (if you specify a git identifier)
</details></p>
The linter will try to detect if the project is a django project and is versioned with git.
## Installation
<p><details><summary><b>Using pip</b></summary>
<pre><code>pip install django-migration-linter</code></pre>
</details></p>
## Usage
`django-migration-linter DJANGO_PROJECT_FOLDER [GIT_COMMIT_ID] [--ignore-name-contains=IGNORE_NAME_CONTAINS] [--include-apps INCLUDE_APPS [INCLUDE_APPS ...] | --exclude-apps EXCLUDE_APPS [EXCLUDE_APPS ...]]`
| Parameter | Description |
| -- | -- |
| `DJANGO_PROJECT_FOLDER` | An absolute or relative path to the django project. |
| `GIT_COMMIT_ID` | If specified, only migrations since this commit will be taken into account. If not specified, the initial repo commit will be used. |
| `--ignore-name-contains IGNORE_NAME_CONTAINS` | Ignore migrations containing this name |
| `--ignore-name IGNORE_NAME [IGNORE_NAME ...]` | Ignore migrations with exactly one of these names |
| `--include-apps INCLUDE_APPS [INCLUDE_APPS ...]` | Check only migrations that are in the specified django apps |
| `--exclude-apps EXCLUDE_APPS [EXCLUDE_APPS ...]` | Ignore migrations that are in the specified django apps |
| `--verbose` or `-v` | print more information during execution |
| `--database DATABASE` | Specify the database for which to generate the SQL. Defaults to *default* |
## Examples
3YOURMIND is running this on [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) with every build getting triggered in this environment.
![](https://i.imgur.com/ocLpQXP.png)
## Tests
The easiest way to run the tests is to invoke [tox](https://pypi.python.org/pypi/tox).
## Contributing
First, thank you very much if you want to contribute to the project.
Please base your work on the `dev` branch and also target this branch in your pull request.
## License
*django-migration-linter* is released under the [Apache 2.0 License](./LICENSE).
+73
View File
@@ -0,0 +1,73 @@
=======================
Django migration linter
=======================
Detect backward incompatible migrations for your django project. It will save you time by making sure migrations will not break anything.
.. image:: https://travis-ci.org/3YOURMIND/django-migration-linter.svg?branch=master
:target: https://travis-ci.org/3YOURMIND/django-migration-linter
.. image:: https://img.shields.io/pypi/v/django-migration-linter.svg
:target: https://pypi.python.org/pypi/django-migration-linter/
.. image:: https://img.shields.io/github/license/3yourmind/django-migration-linter.svg
:target: ./LICENSE
.. image:: https://img.shields.io/badge/PR-welcome-green.svg
:target: https://github.com/3YOURMIND/django-migration-linter/pulls
.. image:: https://img.shields.io/badge/3YOURMIND-Hiring-brightgreen.svg
:target: https://www.3yourmind.com/career
.. image:: https://img.shields.io/github/stars/3YOURMIND/django-migration-linter.svg?style=social&label=Stars
:target: https://github.com/3YOURMIND/django-migration-linter/stargazers
Installation
------------
``pip install django-migration-linter``
Usage
-----
``django-migration-linter DJANGO_PROJECT_FOLDER [GIT_COMMIT_ID] [--ignore-name-contains=IGNORE_NAME_CONTAINS] [--include-apps INCLUDE_APPS [INCLUDE_APPS ...] | --exclude-apps EXCLUDE_APPS [EXCLUDE_APPS ...]]``
================================================== ===========================================================================================================================
Parameter Description
================================================== ===========================================================================================================================
``DJANGO_PROJECT_FOLDER`` An absolute or relative path to the django project.
``GIT_COMMIT_ID`` If specified, only migrations since this commit will be taken into account. If not specified, all migrations will be linted.
``--ignore-name-contains IGNORE_NAME_CONTAINS`` Ignore migrations containing this name.
``--ignore-name IGNORE_NAME [IGNORE_NAME ...]`` Ignore migrations with exactly one of these names.
``--include-apps INCLUDE_APPS [INCLUDE_APPS ...]`` Check only migrations that are in the specified django apps.
``--exclude-apps EXCLUDE_APPS [EXCLUDE_APPS ...]`` Ignore migrations that are in the specified django apps.
``--verbose or -v`` Print more information during execution.
``--database DATABASE`` Specify the database for which to generate the SQL. Defaults to *default*.
================================================== ===========================================================================================================================
Examples
--------
3YOURMIND is running the linter on `Bitbucket Pipelines`_ on every build getting pushed.
Tests
-----
The easiest way to run the tests is to invoke `tox`_.
Contributing
------------
First, thank you very much if you want to contribute to the project.
Please base your work on the ``dev`` branch and also target this branch in your pull request.
License
-------
*django-migration-linter* is released under the `Apache 2.0 License`_.
.. _`Bitbucket Pipelines`: https://bitbucket.org/product/features/pipelines
.. _`tox`: https://pypi.python.org/pypi/tox
.. _`Apache 2.0 License`: https://github.com/3YOURMIND/django-migration-linter/blob/master/LICENSE
+8 -6
View File
@@ -125,16 +125,16 @@ class MigrationLinter(object):
Even if calling a shell is slow and ugly, for now,
it allows to seperate the instances correctly.
"""
git_diff_command = (
sqlmigrate_command = (
'cd {0} && '
'{1} manage.py sqlmigrate {2} {3} '
'--database {4}').format(
self.django_path,
self.python_exe, app_name, migration_name,
self.database)
log.info('Executing {0}'.format(git_diff_command))
log.info('Executing {0}'.format(sqlmigrate_command))
sqlmigrate_process = Popen(
git_diff_command, shell=True, stdout=PIPE, stderr=PIPE)
sqlmigrate_command, shell=True, stdout=PIPE, stderr=PIPE)
sql_statements = []
for line in map(
@@ -152,14 +152,16 @@ class MigrationLinter(object):
def _gather_migrations_git(self, git_commit_id):
migrations = []
# Get changes since specified commit
git_diff_command = 'cd {0} && git diff --name-only {1}'.format(
self.django_path, git_commit_id)
git_diff_command = (
'cd {0} && '
'git diff --name-only --diff-filter=A {1}').format(
self.django_path, git_commit_id)
log.info('Executing {0}'.format(git_diff_command))
diff_process = Popen(
git_diff_command, shell=True, stdout=PIPE, stderr=PIPE)
for line in map(
utils.clean_bytes_to_str, diff_process.stdout.readlines()):
# Only gather lines that include migrations
# Only gather lines that include added migrations
if re.search(
'\/{0}\/.*\.py'.format(self.MIGRATION_FOLDER_NAME),
line) and \
+5
View File
@@ -50,6 +50,11 @@ migration_tests = (
'fn': lambda sql, **kw: re.search('RENAME TABLE', sql) or
re.search('ALTER TABLE .* RENAME TO', sql),
'err_msg': 'RENAMING tables'
}, {
'code': 'ALTER_COLUMN',
'fn': lambda sql, **kw: re.search('ALTER TABLE .* MODIFY', sql),
'err_msg': ('ALTERING columns (Could be backward compatible. '
'You may ignore this migration.)')
}, {
'code': '',
'fn': has_default,
+72
View File
@@ -0,0 +1,72 @@
# Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# You can use this file to integrate the migration-linter into your tests.
# In this example only the migrations after the latest version bump are
# considered.
#
import os
from subprocess import Popen, PIPE
from unittest import TestCase
from django.conf import settings
# Replace that function according to your needs
def read_version_file():
with open('version', 'r') as f:
return '{0}'.format(f.read().replace('\n', ''))
class MigrationTest(TestCase):
ignored_migrations = (
)
excluded_apps = (
)
@classmethod
def setUpClass(cls):
super(MigrationTest, cls).setUpClass()
cls.project_path = os.path.dirname(settings.PROJECT_PATH)
cls.latest_tag = '{0}'.format(read_version_file())
def test_latest_migrations(self):
ignored_migration_parameter = '--ignore-name ' + \
' '.join(self.ignored_migrations) \
if self.ignored_migrations else ''
excluded_apps_parameter = '--exclude-apps ' + \
' '.join(self.excluded_apps) \
if self.excluded_apps else ''
linter_cmd = 'django-migration-linter {0} {1} {2} {3}'.format(
self.project_path,
self.latest_tag,
ignored_migration_parameter,
excluded_apps_parameter)
lint_process = Popen(linter_cmd, shell=True, stdout=PIPE, stderr=PIPE)
lint_process.wait()
if lint_process.returncode != 0:
out, err = lint_process.communicate()
out = out.decode('ascii')
self.fail('The migration linter found errors\n'
'migration command: {0}\n'
'STDOUT: {1}\n'
'STDERR: {2}\n'.
format(linter_cmd, out, err)
)
+3 -7
View File
@@ -12,26 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from codecs import open
from os import path
from setuptools import setup, find_packages
PROJECT_DIR = path.abspath(path.dirname(__file__))
try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except(IOError, ImportError):
long_description = open('README.md').read()
with open(path.join(PROJECT_DIR, 'README.rst')) as f:
long_description = f.read()
install_requirements = [
'django>=1.10',
]
test_requirements = [
'pytest',
'tox',
'django>=1.10',
'django-fake-database-backends',
]
+6 -1
View File
@@ -28,6 +28,8 @@ DROP_COLUMN_PROJECT = os.path.join(
_FIXTURES_FOLDER, 'test_project_drop_column/')
RENAME_COLUMN_PROJECT = os.path.join(
_FIXTURES_FOLDER, 'test_project_rename_column/')
ALTER_COLUMN_PROJECT = os.path.join(
_FIXTURES_FOLDER, 'test_project_alter_column')
RENAME_TABLE_PROJECT = os.path.join(
_FIXTURES_FOLDER, 'test_project_rename_table/')
ADD_NOT_NULL_COLUMN_FOLLOWED_BY_DEFAULT_PROJECT = os.path.join(
@@ -36,6 +38,8 @@ MULTI_COMMIT_PROJECT = os.path.join(
_FIXTURES_FOLDER, 'test_project_multi_commit/')
CORRECT_PROJECT = os.path.join(
_FIXTURES_FOLDER, 'test_correct_project/')
DELETED_MIGRATION_PROJECT = os.path.join(
_FIXTURES_FOLDER, 'test_deleted_migration_project/')
NOT_DJANGO_GIT_PROJECT = os.path.join(
_FIXTURES_FOLDER, 'test_git_project/')
@@ -44,7 +48,8 @@ NOT_GIT_DJANGO_PROJECT = os.path.join(
ALL_GIT_PROJECTS = (
NOT_DJANGO_GIT_PROJECT,
MULTI_COMMIT_PROJECT
MULTI_COMMIT_PROJECT,
DELETED_MIGRATION_PROJECT
)
+15
View File
@@ -129,3 +129,18 @@ class CallLinterFromCommandLineTest(unittest.TestCase):
self.assertEqual(len(lines), 3)
self.assertTrue(lines[0].endswith('OK'))
self.assertTrue(lines[1].startswith('*** Summary'))
def test_call_linter_with_deleted_migrations(self):
cmd = '{0} {1} 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba'.format(
self.linter_exec,
fixtures.DELETED_MIGRATION_PROJECT)
fixtures.prepare_git_project(fixtures.DELETED_MIGRATION_PROJECT)
process = Popen(
cmd, shell=True, stdout=PIPE, stderr=PIPE)
process.wait()
self.assertEqual(process.returncode, 0)
lines = list(map(utils.clean_bytes_to_str, process.stdout.readlines()))
self.assertEqual(len(lines), 3)
self.assertTrue(lines[0].endswith('OK'))
self.assertTrue(lines[1].startswith('*** Summary'))
+15 -10
View File
@@ -25,6 +25,17 @@ class BackwardcompatibilityDetectionTest(unittest.TestCase):
BackwardcompatibilityDetectionTest,
self).tearDown(*args, **kwargs)
def _test_linter_finds_errors(self, path, commit_id=None):
linter = MigrationLinter(path)
linter.lint_all_migrations(git_commit_id=commit_id)
self.assertTrue(linter.has_errors)
def _test_linter_finds_no_errors(self, path, commit_id=None):
linter = MigrationLinter(path)
linter.lint_all_migrations(git_commit_id=commit_id)
self.assertFalse(linter.has_errors)
# *** Tests ***
def test_create_table_with_not_null_column(self):
test_project_path = fixtures.CREATE_TABLE_WITH_NOT_NULL_COLUMN_PROJECT
self._test_linter_finds_no_errors(test_project_path)
@@ -50,6 +61,10 @@ class BackwardcompatibilityDetectionTest(unittest.TestCase):
fixtures.ADD_NOT_NULL_COLUMN_FOLLOWED_BY_DEFAULT_PROJECT
self._test_linter_finds_no_errors(test_project_path)
def test_detect_alter_column(self):
test_project_path = fixtures.ALTER_COLUMN_PROJECT
self._test_linter_finds_errors(test_project_path)
def test_no_specify_git_hash(self):
test_project_path = fixtures.MULTI_COMMIT_PROJECT
fixtures.prepare_git_project(test_project_path)
@@ -66,13 +81,3 @@ class BackwardcompatibilityDetectionTest(unittest.TestCase):
# test_project_path = fixtures.MULTI_COMMIT_PROJECT
# fixtures.prepare_git_project(test_project_path)
# self._test_linter_finds_no_errors(test_project_path, commit_id='tag1')
def _test_linter_finds_errors(self, path, commit_id=None):
linter = MigrationLinter(path)
linter.lint_all_migrations(git_commit_id=commit_id)
self.assertTrue(linter.has_errors)
def _test_linter_finds_no_errors(self, path, commit_id=None):
linter = MigrationLinter(path)
linter.lint_all_migrations(git_commit_id=commit_id)
self.assertFalse(linter.has_errors)
@@ -0,0 +1,3 @@
*.pyc
__pycache__/
*sqlite3
@@ -0,0 +1,16 @@
Delete file and insert new
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Thu Jan 18 23:27:37 2018 +0100
#
# On branch master
# Changes to be committed:
# deleted: test_app/migrations/0002_new_not_null_field.py
# new file: test_app/migrations/0003_new_nullable_field.py
# modified: test_app/models.py
#
# Untracked files:
# git/
#
@@ -0,0 +1 @@
ref: refs/heads/master
@@ -0,0 +1 @@
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba
@@ -0,0 +1,5 @@
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
@@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository.
@@ -0,0 +1,6 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
@@ -0,0 +1,4 @@
0000000000000000000000000000000000000000 0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e David-Wobrock <david.wobrock@gmail.com> 1516314144 +0100 commit (initial): Project init
0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba David-Wobrock <david.wobrock@gmail.com> 1516314322 +0100 commit: Add backward incompatible migration
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba be2fae887ee7ecd2d1e6371af1a865c17414bde9 David-Wobrock <david.wobrock@gmail.com> 1516314457 +0100 commit: Delete file and insert new
be2fae887ee7ecd2d1e6371af1a865c17414bde9 4bdc4ba9e7695893423be1b54f3101d6ccbd11c7 David-Wobrock <david.wobrock@gmail.com> 1516459290 +0100 commit (amend): Delete file and insert new
@@ -0,0 +1,4 @@
0000000000000000000000000000000000000000 0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e David-Wobrock <david.wobrock@gmail.com> 1516314144 +0100 commit (initial): Project init
0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba David-Wobrock <david.wobrock@gmail.com> 1516314322 +0100 commit: Add backward incompatible migration
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba be2fae887ee7ecd2d1e6371af1a865c17414bde9 David-Wobrock <david.wobrock@gmail.com> 1516314457 +0100 commit: Delete file and insert new
be2fae887ee7ecd2d1e6371af1a865c17414bde9 4bdc4ba9e7695893423be1b54f3101d6ccbd11c7 David-Wobrock <david.wobrock@gmail.com> 1516459290 +0100 commit (amend): Delete file and insert new
@@ -0,0 +1,2 @@
x¥�;
1@­sŠéÅ%gC"ÀÎ:ŸY�kQ¯ïŠG°|¯x/I­¥z\õÆ �s²dR´}ÐVóHqrÙzãÜ™ÉkRáÙ¯Òà^%oΛ¤vù‹Ãû‡‡K␍å>$©{Àí ‰`­QkµØeÜù�„:5¹qêP¥«J>ñ
@@ -0,0 +1,3 @@
x]PËjÃ0ìÙ_±�ƒ�;Ôm øRrÈ­·„m­�ZY2zÒ¯¯dåY„˜™�™UÃee™?Ì }L¡•”‰~Öté«G¢¼£@U¤ÐaóU‹^B‘Eö RÀ2/^Ò"O—%O«¼Œ:% ¤³Æ*$Ø0JeÀ
æÌ‘pfœ×QÒÉ/£ÍY7°Þ…1)ô7à•QËk­a¦’«(»€óU�;L0Ãj|(‹£8¢ (Z†ÚŸ“ð89úí|à…ñ67o
Ýú{_&™&=ï�¨¬âu¼¸C;†œê*„a¸“˜Ñø¼U¶¶Fn½4©Ý‹´S­|錊␍µ:’o<ž�ÊmÅ~±Úºßs’T�ÔHB‰Ý&žÏï{øÐ$–s2UºFï„ÁUH÷‚)ãÿüájwr>Dqá£&
@@ -0,0 +1 @@
x¥ŽKJD1Eg5›ü^> ¢àWª*mèÎK¢½}Ÿ¸g÷ÜÁáÐè½-°Á>¬)Õn”8PŽ"¹ZD'…LJ^2»èÅbv5IT7œ²/Ð.oTD‚®VД«·R˜½ËÙPª'ŽA~­Ï1á¿?}Œ2]à™ñtÿÃ×sÇv=Ñè/`6œñÎZxÔFku¼Gè’(Ô3¤Ë'CÛå␍W+W�ÞÎó˜cW?hþVd
@@ -0,0 +1,2 @@
x]OÁj„0ì9_ñ \QÙ‚,xXºlÙÃÞz+"Ѽ•´1‘D ö뛘ݵÛwafÞ̼F¨¶ÅËÓ3¼¡DMGdÐÌpø¤²S�'i’�’�§Y±I³MV@žïò-!­z`‹,a␍ð~Pz„žwÖƒ+ibèCa!­ ÆÀùF…«(¹ƒÑްÃ%9P»žÐc ” eËÑXâcVžSƒ+íùñªÑ^uveÂeÓñn$í± öAü€^8
fJâ…þ␍΂ÛUÉ~ÕÑICju»„°Ò•Žaм§z®¿p¾"µ½Šÿ`y¤ÂXÉ7êF¬}‰Ó!ˆ¢Ç.4 ä$D½TZ£OrĵOw‚%ãÿ~µÚ]�+ò ␍¢�m
@@ -0,0 +1,2 @@
x�ޱ
Â0E]íW¼± RAÈ …‚ƒ›{Hš×´ò’H’¢ŸocÄÉñ^Îá^E^A]ïW}ðôU:ã™V0Ú› ¬×H±(:’1±\2;çº:k7‰~DÒÀß0;¹„C›Û2ü&¬fïÂù$þ“ZIñcuƒ /M*B‘0¦ßÑf&–E+‚Й4ðÝv_ž<4Si
@@ -0,0 +1 @@
xU�Ak„0…{öW ìA·¨¨]l<JK½õVJˆf””8‘)ý÷Mâ®íæÞ¼yßK:¥;8ÕÅÍ²Û z-$�␍¬vȼà ␍·( û�§/N£†2/˼MPå}VYU»kswŠ£'`lXíj�1�Ó¬�…•¤ G¦¤uij‰6£y¹è.¾IŽ&5-)LnÁ;£^ñe�·Ë(ù3å»xl¢Ü8# ¤^â-|Ñ’ØâbŸç8…¸(ŠŠq!á7#m­J±A¢ñ1␍KŸ[ žýó}£«¸…xö‹ÉÎò¼ÐžŸ°�y¼EzÝŸM␍h‡å�Â3úÚê´Û7ä¯dqD³‘|ÛöݬxîêC÷Ú¿ºÁ‹U
@@ -0,0 +1,3 @@
x]�ÍjÃ0„{ÖS,ô !«LÀ‡BHé¡·ÞJ1R´1
òÊX
¥oßHnÝŸ=ÎÎ~3k|0p×Ê›[xDÂY'´`>`Ö4PBŠ�’M»•ͶiA©�ºgì4‡l± kÀ�S˜Œn¸2\ XÃ,úÈ;z#<¯ª“XÅÍŽ1¸ŽÅ É"FèൈyQñ„1õzšx␍\JÙôŽ\rÚóM]\o !Lù�\áÏý¯Ðk½­Vx(u{Ò#v\ó™õ<‹JøÞÓÅ{m<ö§Løg+Z·ü-ž(á€ó’”Ϻ—ù‚_]3t­ý ¡¢o�
@@ -0,0 +1 @@
x+)JMU04±`040031Qˆ�ÏÌË,‰�×+¨dx6÷ÑìM¯9{wk®+�ºqèIOðD¨²âÔ’’̼ôb�²)ûw—Ê<hý¶~ÇÑ3ËŠ*§Ÿõm†*+-Ê+)Ž}z»ûè÷š›O×�KÚúüÄm¶wP%åÅé™ S0°È.Ø~§å´ø¾ ‹¦ƒ)ÒE[^‚D_
@@ -0,0 +1,3 @@
x]�ЭjУ0�{жS,є !ЋPLР�BHщЁЗоJ1RД1
ђЪX
ЅoпHnн�=ЮЮ~3k|0pзЪ�[xDТY'Д`>`ж4PB���MЛ�ЭЖiAЉ�Кgь4�lБ kР�S��nИ2\ XУ,њШ;z#<ЏЊ�XХЭ�1И�Х Щ"FшрЕ�yQё�1ѕz�x␍\Jйє�\rкѓM]\o !Lљ�\сЯ§ЏаkН­Vx(u{в#v\ѓ�ѕ<�JјогХ{m<іЇLјg+ZЗќ-�(с�ѓ��ЯК�љ�_]3t­§ Ђ№o�
@@ -0,0 +1 @@
x¥ŽAn1 EYçÞ£¢1N2Œ„*Ü¡kÇvÚˆ™ JÓrýâ]¾÷¥§/uYJ‡c ]of@¢j^#“ž‚¤ƒ÷qœÐ&’ñdÂB¦ÁݹÙÚa[MrDœèD(a¦ØÛ8L)'�Èž}bÇ?ý«6¸òoÑ·�šZ•œõ‰‡Ç /Ÿ —ù uyߺ ½#ì·Ùíh·$ÜÕfë¹Ì¼*”õÛZ‡Õî7zRY
@@ -0,0 +1,2 @@
xm�AkĂ0 …wöŻ>µĐĹt �íJÇÖÚ±câÄJęb[ÁVŰíß/I[ča'!žôľ'•ŽJx|xş“RŠďÍb …Ú6PSgcĚçm¤=V —š ±dŔź–&ŕÂyY;§K‡ hđdďŃÁQG;HA{4Pşmť­4[
EŃů˝uDOÁ†î(tć6AmN !Šs›ž•2TĄĚěuhčš©"Ż0¨i6ťŞť�”ÁÖŃŻÇŔꔫD¦°ľĄČ@I�:’‡łKVuđ¬�Ë@�ś÷}~UJ†ŁŤ˛„l°ÖÇ#9{]-ÖůfľÝ.W‹Mţąž}}Ěĺäđ?�Mîm‡Ó®íM؆&ɱ7 x�˙řٱř°č™ž
@@ -0,0 +1 @@
4bdc4ba9e7695893423be1b54f3101d6ccbd11c7
@@ -0,0 +1,22 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_deleted_migration_project.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
@@ -0,0 +1,5 @@
from django.apps import AppConfig
class TestAppConfig(AppConfig):
name = 'test_app'
@@ -0,0 +1,21 @@
# Generated by Django 2.0.1 on 2018-01-18 22:24
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='A',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('null_field', models.IntegerField(null=True)),
],
),
]
@@ -0,0 +1,15 @@
from django.db import migrations
from django.db import models
class Migration(migrations.Migration):
dependencies = [('test_app', '0001_initial'),]
operations = [
migrations.AddField(
model_name='a',
name='new_char_nullable_test_field',
field=models.CharField(max_length=30, null=True),
),
]
@@ -0,0 +1,6 @@
from django.db import models
class A(models.Model):
null_field = models.IntegerField(null=True)
new_not_null_field = models.IntegerField(null=False)
new_char_nullable_test_field = models.CharField(max_length=30, null=True)
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.
@@ -0,0 +1,120 @@
"""
Django settings for test_deleted_migration_project project.
Generated by 'django-admin startproject' using Django 1.11.6.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'gtb+mohs%gf0+#fr89vw7e&#edmv=q8!iv+n&j_soawk$tkj3^'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'test_app'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'test_deleted_migration_project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'test_deleted_migration_project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django_fake_database_backends.backends.mysql',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
@@ -0,0 +1,21 @@
"""linter_test_project URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
]
@@ -0,0 +1,16 @@
"""
WSGI config for linter_test_project project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_deleted_migration_project.settings")
application = get_wsgi_application()
@@ -0,0 +1,3 @@
*.pyc
__pycache__/
*sqlite3
@@ -0,0 +1,22 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project_alter_column.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
@@ -0,0 +1,5 @@
from django.apps import AppConfig
class TestAppConfig(AppConfig):
name = 'test_app'
@@ -0,0 +1,21 @@
# Generated by Django 2.0.1 on 2018-01-14 12:48
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='A',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=10, null=True)),
],
),
]
@@ -0,0 +1,18 @@
# Generated by Django 2.0.1 on 2018-01-14 12:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('test_app', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='a',
name='code',
field=models.IntegerField(null=True),
),
]
@@ -0,0 +1,4 @@
from django.db import models
class A(models.Model):
code = models.IntegerField(null=True)
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.
@@ -0,0 +1,120 @@
"""
Django settings for test_project_alter_column project.
Generated by 'django-admin startproject' using Django 1.11.6.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'gtb+mohs%gf0+#fr89vw7e&#edmv=q8!iv+n&j_soawk$tkj3^'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'test_app'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'test_project_alter_column.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'test_project_alter_column.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django_fake_database_backends.backends.mysql'
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
@@ -0,0 +1,21 @@
"""linter_test_project URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
]
@@ -0,0 +1,16 @@
"""
WSGI config for linter_test_project project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project_alter_column.settings")
application = get_wsgi_application()
@@ -1,15 +0,0 @@
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
test -x "$GIT_DIR/hooks/commit-msg" &&
exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
:
@@ -1,24 +0,0 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
@@ -1,8 +0,0 @@
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
exec git update-server-info
@@ -1,14 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
:
@@ -1,49 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
@@ -1,54 +0,0 @@
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Handle delete
:
else
if [ "$remote_sha" = $z40 ]
then
# New branch, examine all commits
range="$local_sha"
else
# Update to existing branch, examine new commits
range="$remote_sha..$local_sha"
fi
# Check for WIP commit
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
if [ -n "$commit" ]
then
echo "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0
@@ -1,169 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi
case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}
# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi
# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up-to-date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi
<<\DOC_END
This sample hook safeguards topic branches that have been
published from being rewound.
The workflow assumed here is:
* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).
* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.
* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.
The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.
With this workflow, you would want to know:
(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.
(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".
Let's look at this example:
o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"
A, B and C are topic branches.
* A has one fix since it was merged up to "next".
* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.
* C has not merged to "next" at all.
We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.
To compute (1):
git rev-list ^master ^topic next
git rev-list ^master next
if these match, topic has not merged in next at all.
To compute (2):
git rev-list master..topic
if this is empty, it is fully merged to "master".
DOC_END
@@ -1,36 +0,0 @@
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
# This hook includes three examples. The first comments out the
# "Conflicts:" part of a merge commit.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
case "$2,$3" in
merge,)
/usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$1" ;;
*) ;;
esac
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
@@ -1,128 +0,0 @@
#!/bin/sh
#
# An example hook script to blocks unannotated tags from entering.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# To enable this hook, rename this file to "update".
#
# Config
# ------
# hooks.allowunannotated
# This boolean sets whether unannotated tags will be allowed into the
# repository. By default they won't be.
# hooks.allowdeletetag
# This boolean sets whether deleting tags will be allowed in the
# repository. By default they won't be.
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
# hooks.denycreatebranch
# This boolean sets whether remotely creating branches will be denied
# in the repository. By default this is allowed.
#
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi
# --- Config
allowunannotated=$(git config --bool hooks.allowunannotated)
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
denycreatebranch=$(git config --bool hooks.denycreatebranch)
allowdeletetag=$(git config --bool hooks.allowdeletetag)
allowmodifytag=$(git config --bool hooks.allowmodifytag)
# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
case "$projectdesc" in
"Unnamed repository"* | "")
echo "*** Project description file hasn't been set" >&2
exit 1
;;
esac
# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero="0000000000000000000000000000000000000000"
if [ "$newrev" = "$zero" ]; then
newrev_type=delete
else
newrev_type=$(git cat-file -t $newrev)
fi
case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
if [ "$allowunannotated" != "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
fi
;;
refs/tags/*,delete)
# delete tag
if [ "$allowdeletetag" != "true" ]; then
echo "*** Deleting a tag is not allowed in this repository" >&2
exit 1
fi
;;
refs/tags/*,tag)
# annotated tag
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
then
echo "*** Tag '$refname' already exists." >&2
echo "*** Modifying a tag is not allowed in this repository." >&2
exit 1
fi
;;
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/remotes/*,commit)
# tracking branch
;;
refs/remotes/*,delete)
# delete tracking branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
exit 1
fi
;;
*)
# Anything else (is there anything else?)
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
exit 1
;;
esac
# --- Finished
exit 0
@@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project_add_not_null_column.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project_rename_table.settings")
application = get_wsgi_application()