Browse Source

exit when process no utf-8 file

李昂 1 year ago
parent
commit
4452148864
1 changed files with 6 additions and 1 deletions
  1. 6 1
      tools/pika-patch-tool.py

+ 6 - 1
tools/pika-patch-tool.py

@@ -49,7 +49,12 @@ for root, apply_dirs, files in os.walk('.'):
             result = subprocess.run(diff_command, stdout=subprocess.PIPE)
             if result.stdout:
                 # 确保使用UTF-8编码解码stdout
-                diff_output = result.stdout.decode('utf-8')
+                try:
+                    diff_output = result.stdout.decode('utf-8')
+                except Exception as e:
+                    print(f"Failed to decode diff output: {e}")
+                    print("Skipping file:", target_file)
+                    exit(-1)
                 print(diff_output)
                 # 使用UTF-8编码打开文件进行写入
                 with open("/tmp/base/changes.patch", "a", encoding='utf-8') as patch_file: