mirror of
git://git.yoctoproject.org/yocto-autobuilder2.git
synced 2025-07-19 20:59:02 +02:00
wikilog: Ensure empty wiki page is handled correctly for page init
When a wiki page is empty, or only contains a single entry, ensure the code still works and use empty content to initialise it. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
646ff04e8c
commit
22d8500664
|
@ -136,6 +136,8 @@ class YPWiki(object):
|
||||||
|
|
||||||
parsed = self.parse_json(req)
|
parsed = self.parse_json(req)
|
||||||
pageid = sorted(parsed['query']['pages'].keys())[-1]
|
pageid = sorted(parsed['query']['pages'].keys())[-1]
|
||||||
|
blurb, entries = "\n", ""
|
||||||
|
if 'revisions' in parsed['query']['pages'][pageid]:
|
||||||
content = parsed['query']['pages'][pageid]['revisions'][0]['*']
|
content = parsed['query']['pages'][pageid]['revisions'][0]['*']
|
||||||
blurb, entries = content.split('==', 1)
|
blurb, entries = content.split('==', 1)
|
||||||
# ensure we keep only a single newline after the blurb
|
# ensure we keep only a single newline after the blurb
|
||||||
|
|
|
@ -252,9 +252,14 @@ class WikiLog(service.BuildbotService):
|
||||||
entry_title = next(it)
|
entry_title = next(it)
|
||||||
while entry_title.group(1) != title:
|
while entry_title.group(1) != title:
|
||||||
entry_title = next(it)
|
entry_title = next(it)
|
||||||
next_title = next(it)
|
|
||||||
head = entries[:entry_title.start()]
|
head = entries[:entry_title.start()]
|
||||||
|
try:
|
||||||
|
next_title = next(it)
|
||||||
tail = entries[next_title.start():]
|
tail = entries[next_title.start():]
|
||||||
|
except StopIteration:
|
||||||
|
# There was no following entry
|
||||||
|
tail = ""
|
||||||
|
|
||||||
update = head + "==[" + new_title + "]==\n" + new_entry + tail
|
update = head + "==[" + new_title + "]==\n" + new_entry + tail
|
||||||
|
|
||||||
cookies = self.wiki.login()
|
cookies = self.wiki.login()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user