From: Teemu Kokkonen Date: Wed, 20 Nov 2013 13:52:17 +0000 (+0200) Subject: Change filename length restriction to 60 characters & word truncation X-Git-Tag: rel_0_6_1~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71b63618a86a3921593917ea9072f4149da2dfef;p=thirdparty%2Fsqlalchemy%2Falembic.git Change filename length restriction to 60 characters & word truncation Example of a longer filename: - 3e12cdb9209d_alter_user_table_telephone_and_mobile_columns.py Example of a filename that has been truncated: - 12894284029g_create_partial_index_for_article_telephone_column_and_.py --- diff --git a/alembic/script.py b/alembic/script.py index 8f3d11f0..f8ef9603 100644 --- a/alembic/script.py +++ b/alembic/script.py @@ -220,7 +220,9 @@ class ScriptDirectory(object): return map_ def _rev_path(self, rev_id, message, create_date): - slug = "_".join(_slug_re.findall(message or "")).lower()[0:20] + slug = "_".join(_slug_re.findall(message or "")).lower() + if len(slug) > 60: + slug = slug[:60].rsplit('_', 1)[0]+'_' filename = "%s.py" % ( self.file_template % { 'rev': rev_id, diff --git a/tests/test_revision_create.py b/tests/test_revision_create.py index a74346e8..313be0d0 100644 --- a/tests/test_revision_create.py +++ b/tests/test_revision_create.py @@ -76,7 +76,8 @@ class GeneralOrderedTests(unittest.TestCase): "I'd like it to\nhave\nnewlines") assert os.access( os.path.join(env.dir, 'versions', - '%s_this_is_a_really_lon.py' % rid), os.F_OK) + '%s_this_is_a_really_long_name_with_lots_of_' + 'characters_and_also_.py' % rid), os.F_OK) @classmethod