summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Cope <olly@ollycope.com>2016-07-03 07:57:38 +0000
committerOlly Cope <olly@ollycope.com>2016-07-03 07:57:38 +0000
commit483044a4ab17755dd4e5537304d6dfb3c98474c0 (patch)
tree1fa2606a927782fda97bbb3bd6ab075c4419ffbb
parentac796c55ddc75417c05f41f3b4e65a1a02d79b8b (diff)
downloadyoyo-483044a4ab17755dd4e5537304d6dfb3c98474c0.tar.gz
Use Migration.load() to read new migrations' docstrings
This fixes an exception on interactive migration creation, caused by a required variable not being present in the migration module's namespace.
-rwxr-xr-xCHANGELOG.rst6
-rwxr-xr-xyoyo/migrations.py1
-rw-r--r--yoyo/scripts/newmigration.py7
3 files changed, 11 insertions, 3 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index dfa6a36..f1a2292 100755
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,12 @@
CHANGELOG
---------
+5.0.3
+~~~~~
+
+* Bugfix: fixed exception when creating a new migration interactively
+ with `yoyo new`
+
5.0.2 (released 2016-06-21)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/yoyo/migrations.py b/yoyo/migrations.py
index 9e84900..dfc0c32 100755
--- a/yoyo/migrations.py
+++ b/yoyo/migrations.py
@@ -81,6 +81,7 @@ class Migration(object):
if None in self._depends:
raise exceptions.BadMigration(
"Could not resolve dependencies in {}".format(self.path))
+ self.ns = ns
self.source = source
self.steps = list(collector.steps)
diff --git a/yoyo/scripts/newmigration.py b/yoyo/scripts/newmigration.py
index 7e7c36b..449349e 100644
--- a/yoyo/scripts/newmigration.py
+++ b/yoyo/scripts/newmigration.py
@@ -31,7 +31,7 @@ from slugify import slugify
from yoyo import default_migration_table
from yoyo.compat import configparser
from yoyo.config import CONFIG_NEW_MIGRATION_COMMAND_KEY
-from yoyo.migrations import read_migrations, heads
+from yoyo.migrations import read_migrations, heads, Migration
from yoyo import utils
from .main import InvalidArgument
@@ -170,9 +170,10 @@ def create_with_editor(config, directory, migration_source):
print("abort: no changes made")
return None
- modname = path.splitext(path.basename(tmpfile.name))[0]
try:
- message = __import__(modname).__doc__
+ migration = Migration(None, tmpfile.name)
+ migration.load()
+ message = migration.ns['__doc__']
break
except Exception:
message = ''