Skip to content

Commit

Permalink
Treat the case when file is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Dec 15, 2023
1 parent af635f1 commit 26ffdaa
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .ci/create-changes-html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ for block in diff_blocks:
doc = match.group(1)
path = 'html/' + doc
file_path = os.path.join('$DOC_REPOSITORY', doc)
with open(file_path, 'r') as file:
content = file.readlines()
try:
with open(file_path, 'r') as file:
content = file.readlines()
except FileNotFoundError:
content = []
count = 0
for line in block.splitlines():
if line.startswith('@@ -'):
Expand All @@ -77,8 +80,9 @@ for block in diff_blocks:
count += 1
content[i] = f'<span id="hunk{count}" style="visibility: hidden;"></span>' + content[i]
break
with open(file_path, 'w') as file:
file.writelines(content)
if content:
with open(file_path, 'w') as file:
file.writelines(content)
hunks = '&nbsp;'.join(f'<a href="{path}#hunk{i+1}" class="hunk" target="_blank">#{i + 1}</a>' for i in range(count))
out_blocks.append(f'<p class="diff"><a href="{path}">{doc}</a>&nbsp;' + hunks + '&emsp;</p>'
+ '\n<pre><code class="language-diff">'
Expand Down

0 comments on commit 26ffdaa

Please sign in to comment.