3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-26 02:01:21 +00:00

Add proper error handling for empty file list and preserve filepath integrity

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-12 17:42:24 +00:00 committed by Nikolaj Bjorner
parent 86c2fa7a9d
commit d7f87d7b19

View file

@ -720,12 +720,14 @@ jobs:
# Read NUL-delimited input # Read NUL-delimited input
with open("release_files.txt", "rb") as f: with open("release_files.txt", "rb") as f:
content = f.read() content = f.read()
# Handle empty file case explicitly
if content.rstrip(b"\0"):
# Strip trailing NUL before splitting to avoid empty trailing element # Strip trailing NUL before splitting to avoid empty trailing element
files = content.decode("utf-8").rstrip("\0").split("\0") if content else [] files = content.decode("utf-8").rstrip("\0").split("\0")
for filepath in files: for filepath in files:
filepath = filepath.strip() if not filepath: # Skip empty strings
if not filepath:
continue continue
basename = os.path.basename(filepath) basename = os.path.basename(filepath)
@ -735,7 +737,7 @@ jobs:
seen_basenames.add(basename) seen_basenames.add(basename)
unique_files.append(filepath) unique_files.append(filepath)
# Write NUL-delimited output # Write NUL-delimited output with trailing NUL
with open("release_files_dedup.txt", "wb") as f: with open("release_files_dedup.txt", "wb") as f:
if unique_files: if unique_files:
f.write("\0".join(unique_files).encode("utf-8")) f.write("\0".join(unique_files).encode("utf-8"))
@ -743,18 +745,24 @@ jobs:
DEDUP_SCRIPT DEDUP_SCRIPT
# Read files into bash array safely using NUL delimiter # Read files into bash array safely using NUL delimiter
declare -a FILES # Only if the deduplicated file list is not empty
while IFS= read -r -d $'\0' file; do if [ -s release_files_dedup.txt ]; then
FILES+=("$file") declare -a FILES
done < release_files_dedup.txt while IFS= read -r -d $'\0' file; do
FILES+=("$file")
done < release_files_dedup.txt
# Create release with properly quoted file arguments # Create release with properly quoted file arguments
gh release create Nightly \ gh release create Nightly \
--title "Nightly" \ --title "Nightly" \
--notes "Automated nightly build from commit ${{ github.sha }}" \ --notes "Automated nightly build from commit ${{ github.sha }}" \
--prerelease \ --prerelease \
--target ${{ github.sha }} \ --target ${{ github.sha }} \
"${FILES[@]}" "${FILES[@]}"
else
echo "No files to release after deduplication"
exit 1
fi
publish-test-pypi: publish-test-pypi: