Listing all entries in DayOne Classic journal throws IndexError (#786)

* Reproduce bug in #780
🎵 I have no body, no body to love me... 🎵
The bug is cause by a DayOne entry that has to entry body.

* Deal with empty bodies
Close #780.

* [Travis-CI] add "tree" command to debug missing files
* Fix file location
I have no idea why, but it ran locally fine without issue. Travis is more particular...
This commit is contained in:
MinchinWeb 2020-02-08 14:14:33 -07:00 committed by GitHub
parent 7ac3e3160d
commit e5d7845f18
5 changed files with 65 additions and 8 deletions

View file

@ -9,8 +9,14 @@ git:
depth: false depth: false
autocrlf: false autocrlf: false
addons:
apt:
packages:
- tree
before_install: before_install:
- date - date
- tree
install: install:
- pip install poetry - pip install poetry

View file

@ -0,0 +1,12 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: false
highlight: true
journals:
default: features/journals/bug780.dayone
linewrap: 80
tagsymbols: '@'
template: false
timeformat: '%Y-%m-%d %H:%M'
indent_character: "|"

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Activity</key>
<string>Stationary</string>
<key>Creation Date</key>
<date>2019-12-30T21:28:54Z</date>
<key>Entry Text</key>
<string></string>
<key>Starred</key>
<false />
<key>UUID</key>
<string>48A25033B34047C591160A4480197D8B</string>
<key>Creator</key>
<dict>
<key>Device Agent</key>
<string>PC</string>
<key>Generation Date</key>
<date>2019-12-30T21:28:54Z</date>
<key>Host Name</key>
<string>LE-TREPORT</string>
<key>OS Agent</key>
<string>Microsoft Windows/10 Home</string>
<key>Software Agent</key>
<string>Journaley/2.1</string>
</dict>
<key>Tags</key>
<array>
<string>i_have_no_body</string>
</array>
</dict>
</plist>

View file

@ -15,13 +15,6 @@ Feature: Zapped bugs should stay dead.
Then we should see the message "Entry added" Then we should see the message "Entry added"
and the journal should contain "[2013-11-30 15:42] Project Started." and the journal should contain "[2013-11-30 15:42] Project Started."
Scenario: Date in the future should be parsed correctly
# https://github.com/maebert/jrnl/issues/185
Given we use the config "basic.yaml"
When we run "jrnl 26/06/2019: Planet? Earth. Year? 2019."
Then we should see the message "Entry added"
and the journal should contain "[2019-06-26 09:00] Planet?"
Scenario: Loading entry with ambiguous time stamp Scenario: Loading entry with ambiguous time stamp
#https://github.com/maebert/jrnl/issues/153 #https://github.com/maebert/jrnl/issues/153
Given we use the config "bug153.yaml" Given we use the config "bug153.yaml"
@ -32,6 +25,19 @@ Feature: Zapped bugs should stay dead.
2013-10-27 03:27 Some text. 2013-10-27 03:27 Some text.
""" """
Scenario: Date in the future should be parsed correctly
# https://github.com/maebert/jrnl/issues/185
Given we use the config "basic.yaml"
When we run "jrnl 26/06/2019: Planet? Earth. Year? 2019."
Then we should see the message "Entry added"
and the journal should contain "[2019-06-26 09:00] Planet?"
Scenario: Empty DayOne entry bodies should not error
# https://github.com/jrnl-org/jrnl/issues/780
Given we use the config "bug780.yaml"
When we run "jrnl --short"
Then we should get no error
Scenario: Title with an embedded period. Scenario: Title with an embedded period.
Given we use the config "basic.yaml" Given we use the config "basic.yaml"
When we run "jrnl 04-24-2014: Created a new website - empty.com. Hope to get a lot of traffic." When we run "jrnl 04-24-2014: Created a new website - empty.com. Hope to get a lot of traffic."

View file

@ -22,7 +22,7 @@ class Entry:
def _parse_text(self): def _parse_text(self):
raw_text = self.text raw_text = self.text
lines = raw_text.splitlines() lines = raw_text.splitlines()
if lines[0].strip().endswith("*"): if lines and lines[0].strip().endswith("*"):
self.starred = True self.starred = True
raw_text = lines[0].strip("\n *") + "\n" + "\n".join(lines[1:]) raw_text = lines[0].strip("\n *") + "\n" + "\n".join(lines[1:])
self._title, self._body = split_title(raw_text) self._title, self._body = split_title(raw_text)