summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-11-23 11:48:09 +0200
committerLars Wirzenius <liw@liw.fi>2014-11-23 11:48:09 +0200
commit6eec9f17e97e408b4c82f001ffc8a7ea399a0ed6 (patch)
treed9effdb8202f89bf820bf16ba39e4bbe268c5edf
parentc1ac7db2f3ab0d64e82c569a4282f05041bd0d53 (diff)
downloadjt-6eec9f17e97e408b4c82f001ffc8a7ea399a0ed6.tar.gz
Check that topic pages exist
-rw-r--r--NEWS1
-rwxr-xr-xjt6
-rw-r--r--yarns/030-topics.yarn5
3 files changed, 12 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 9104007..ca9a21f 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Version 0.4, released UNRELEASED
--------------------------------
* Method names (`_commit_to_git`, `_push_to_git`) in calls fixed.
+* With `jt new --topic=foo`, the topic page foo.mdwn must exist.
Version 0.3, released 2014-11-22
--------------------------------
diff --git a/jt b/jt
index 1b7a193..b1a96bf 100755
--- a/jt
+++ b/jt
@@ -118,6 +118,8 @@ class NewCommand(Command):
self._app.settings.require('source')
topic = self._app.settings['topic']
+ if topic and not self._topic_page_exists(topic):
+ raise cliapp.AppException('Topic %s does not exist yet' % topic)
values = {
'title': args[0],
@@ -130,6 +132,10 @@ class NewCommand(Command):
draft_id = drafts_dir.create_draft(template % values)
self._app.edit_file(drafts_dir.get_draft_pathname(draft_id))
+ def _topic_page_exists(self, topic):
+ pathname = os.path.join(self._app.settings['source'], topic + '.mdwn')
+ return os.path.exists(pathname)
+
def _get_topic_link(self, topic):
if topic:
return 'Part of [[%s]]' % topic
diff --git a/yarns/030-topics.yarn b/yarns/030-topics.yarn
index e931ae3..cad687c 100644
--- a/yarns/030-topics.yarn
+++ b/yarns/030-topics.yarn
@@ -15,3 +15,8 @@ topic.
GIVEN the time is 2014-11-20 20:04:08
WHEN I run jt new --topic=research/2014/dishwasher TITLE
THEN file SRC/drafts/0.mdwn matches research/2014/dishwasher
+
+We should get an error if the topic doesn't exist.
+
+ WHEN I try to run jt new --topic=does/not/exist YEEHAA
+ THEN it fails