From 26ffdaaa5ad01da3b5156d3d7e50cb77562ce24e Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Fri, 15 Dec 2023 15:14:05 +0900 Subject: [PATCH 1/2] Treat the case when file is removed --- .ci/create-changes-html.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh index cce6c45acac..8cc243555c9 100755 --- a/.ci/create-changes-html.sh +++ b/.ci/create-changes-html.sh @@ -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('@@ -'): @@ -77,8 +80,9 @@ for block in diff_blocks: count += 1 content[i] = f'' + 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 = ' '.join(f'#{i + 1}' for i in range(count)) out_blocks.append(f'

{doc} ' + hunks + ' 

' + '\n
'

From 778195a31915bf13ccab2560f60e2e24820a173d Mon Sep 17 00:00:00 2001
From: Kwankyu Lee 
Date: Sat, 16 Dec 2023 20:54:44 +0900
Subject: [PATCH 2/2] Small edit

---
 .ci/create-changes-html.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.ci/create-changes-html.sh b/.ci/create-changes-html.sh
index 8cc243555c9..cdae3a49df8 100755
--- a/.ci/create-changes-html.sh
+++ b/.ci/create-changes-html.sh
@@ -62,7 +62,6 @@ for block in diff_blocks:
     match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE)
     if match:
         doc = match.group(1)
-        path = 'html/' + doc
         file_path = os.path.join('$DOC_REPOSITORY', doc)
         try:
             with open(file_path, 'r') as file:
@@ -83,6 +82,7 @@ for block in diff_blocks:
         if content:
             with open(file_path, 'w') as file:
                 file.writelines(content)
+        path = 'html/' + doc
         hunks = ' '.join(f'#{i + 1}' for i in range(count))
         out_blocks.append(f'

{doc} ' + hunks + ' 

' + '\n
'