From: Markus Mattes Date: Mon, 28 Nov 2016 22:32:27 +0000 (-0500) Subject: Ignore py files generated by emacs X-Git-Tag: rel_0_8_10~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=053062c2ee5a0c8d947e35ba27a6c60808dfea5f;p=thirdparty%2Fsqlalchemy%2Falembic.git Ignore py files generated by emacs Added a file ignore for Python files of the form ``.#.py``, which are generated by the Emacs editor. Pull request courtesy Markus Mattes. Change-Id: I06861c2ba7b8e6730948c01ff0690b50bdb26f0f Pull-request: https://github.com/zzzeek/alembic/pull/32 Fixes: #356 --- diff --git a/alembic/script/base.py b/alembic/script/base.py index 3a0a6fd9..a79ec09c 100644 --- a/alembic/script/base.py +++ b/alembic/script/base.py @@ -9,8 +9,8 @@ from ..runtime import migration from contextlib import contextmanager -_sourceless_rev_file = re.compile(r'(?!__init__)(.*\.py)(c|o)?$') -_only_source_rev_file = re.compile(r'(?!__init__)(.*\.py)$') +_sourceless_rev_file = re.compile(r'(?!\.\#|__init__)(.*\.py)(c|o)?$') +_only_source_rev_file = re.compile(r'(?!\.\#|__init__)(.*\.py)$') _legacy_rev = re.compile(r'([a-f0-9]+)\.py$') _mod_def_re = re.compile(r'(upgrade|downgrade)_([a-z0-9]+)') _slug_re = re.compile(r'\w+') diff --git a/docs/build/changelog.rst b/docs/build/changelog.rst index f4b332cd..b2ac0843 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -6,6 +6,14 @@ Changelog .. changelog:: :version: 0.8.10 + .. change:: 356 + :tags: bug, versioning + :tickets: 356 + + Added a file ignore for Python files of the form ``.#.py``, + which are generated by the Emacs editor. Pull request courtesy + Markus Mattes. + .. changelog:: :version: 0.8.9 :released: November 28, 2016 diff --git a/tests/test_script_consumption.py b/tests/test_script_consumption.py index fc9d9aa0..a86430f7 100644 --- a/tests/test_script_consumption.py +++ b/tests/test_script_consumption.py @@ -301,7 +301,7 @@ def downgrade(): Script._from_path, script, path) -class IgnoreInitTest(TestBase): +class IgnoreFilesTest(TestBase): sourceless = False def setUp(self): @@ -312,12 +312,11 @@ class IgnoreInitTest(TestBase): def tearDown(self): clear_staging_env() - def _test_ignore_init_py(self, ext): - """test that __init__.py is ignored.""" + def _test_ignore_file_py(self, fname): command.revision(self.cfg, message="some rev") script = ScriptDirectory.from_config(self.cfg) - path = os.path.join(script.versions, "__init__.%s" % ext) + path = os.path.join(script.versions, fname) with open(path, 'w') as f: f.write( "crap, crap -> crap" @@ -326,20 +325,42 @@ class IgnoreInitTest(TestBase): script.get_revision('head') - def test_ignore_py(self): + def _test_ignore_init_py(self, ext): + """test that __init__.py is ignored.""" + + self._test_ignore_file_py("__init__.%s" % ext) + + def _test_ignore_dot_hash_py(self, ext): + """test that .#test.py is ignored.""" + + self._test_ignore_file_py(".#test.%s" % ext) + + def test_ignore_init_py(self): self._test_ignore_init_py("py") - def test_ignore_pyc(self): + def test_ignore_init_pyc(self): self._test_ignore_init_py("pyc") - def test_ignore_pyx(self): + def test_ignore_init_pyx(self): self._test_ignore_init_py("pyx") - def test_ignore_pyo(self): + def test_ignore_init_pyo(self): self._test_ignore_init_py("pyo") + def test_ignore_dot_hash_py(self): + self._test_ignore_dot_hash_py("py") + + def test_ignore_dot_hash_pyc(self): + self._test_ignore_dot_hash_py("pyc") + + def test_ignore_dot_hash_pyx(self): + self._test_ignore_dot_hash_py("pyx") + + def test_ignore_dot_hash_pyo(self): + self._test_ignore_dot_hash_py("pyo") + -class SourcelessIgnoreInitTest(IgnoreInitTest): +class SourcelessIgnoreFilesTest(IgnoreFilesTest): sourceless = True