Skip to content

Commit 8c97fc9

Browse files
authored
fix: allow for deleted files to be considered when commiting (#2566)
1 parent 978c378 commit 8c97fc9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/create-signed-commit.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,14 @@ MODIFIED_FILES=$(git diff --name-only --cached)
5656
echo "Modified files: $MODIFIED_FILES"
5757

5858
# Create blob and tree
59-
NEW_TREE_ARRAY="["
60-
for FILE_PATH in $MODIFIED_FILES; do
59+
NEW_TREE_ARRAY="["
60+
for FILE_PATH in $MODIFIED_FILES; do
61+
if [[ ! -f "$FILE_PATH" ]]; then
62+
echo "Detected deleted file: $FILE_PATH"
63+
NEW_TREE_ARRAY="${NEW_TREE_ARRAY}{\"path\": \"$FILE_PATH\", \"mode\": \"100644\", \"type\": \"blob\", \"sha\": null},"
64+
continue
65+
fi
66+
6167
# Read file content encoded to base64
6268
ENCODED_CONTENT=$(base64 -w0 < "${FILE_PATH}")
6369

@@ -71,7 +77,7 @@ for FILE_PATH in $MODIFIED_FILES; do
7177
rm content.blob
7278

7379
# Append file info to tree JSON
74-
NEW_TREE_ARRAY="${NEW_TREE_ARRAY}{\"path\": \"$FILE_PATH\", \"mode\": \"100644\", \"type\": \"blob\", \"sha\": \"$BLOB_SHA\"},"
80+
NEW_TREE_ARRAY="${NEW_TREE_ARRAY}{\"path\": \"$FILE_PATH\", \"mode\": \"100644\", \"type\": \"blob\", \"sha\": \"$BLOB_SHA\"},"
7581
done
7682

7783
# Remove trailing comma and close the array

0 commit comments

Comments
 (0)