Skip to content

Commit 26ffdaa

Browse files
committed
Treat the case when file is removed
1 parent af635f1 commit 26ffdaa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

.ci/create-changes-html.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ for block in diff_blocks:
6464
doc = match.group(1)
6565
path = 'html/' + doc
6666
file_path = os.path.join('$DOC_REPOSITORY', doc)
67-
with open(file_path, 'r') as file:
68-
content = file.readlines()
67+
try:
68+
with open(file_path, 'r') as file:
69+
content = file.readlines()
70+
except FileNotFoundError:
71+
content = []
6972
count = 0
7073
for line in block.splitlines():
7174
if line.startswith('@@ -'):
@@ -77,8 +80,9 @@ for block in diff_blocks:
7780
count += 1
7881
content[i] = f'<span id="hunk{count}" style="visibility: hidden;"></span>' + content[i]
7982
break
80-
with open(file_path, 'w') as file:
81-
file.writelines(content)
83+
if content:
84+
with open(file_path, 'w') as file:
85+
file.writelines(content)
8286
hunks = '&nbsp;'.join(f'<a href="{path}#hunk{i+1}" class="hunk" target="_blank">#{i + 1}</a>' for i in range(count))
8387
out_blocks.append(f'<p class="diff"><a href="{path}">{doc}</a>&nbsp;' + hunks + '&emsp;</p>'
8488
+ '\n<pre><code class="language-diff">'

0 commit comments

Comments
 (0)