sdm710-common: update script to handle added and deleted blobs

Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
This commit is contained in:
Chenyang Zhong 2020-09-29 21:57:04 -04:00 committed by Ultra119
parent 39a599c948
commit 1d65c45429

View file

@ -16,6 +16,7 @@
# #
# HISTORY # HISTORY
# 2020/06/19 : Script creation # 2020/06/19 : Script creation
# 2020/09/29 : Updated script to handle added and deleted blobs
# #
#============================================================================== #==============================================================================
# #
@ -46,16 +47,36 @@ echo "$(git show -s --format='%h %s' ${COMMIT})"
echo "========================================================" echo "========================================================"
# iterate through changed files in the commit # iterate through changed files in the commit
for file in $(git diff-tree --no-commit-id --name-only -r "${COMMIT}") git diff-tree --no-commit-id --name-status -r ${COMMIT} | while read line ;
do do
# separate status and file name
read -ra arr_line <<< "${line}"
status=${arr_line[0]}
file=${arr_line[1]}
# remove directory prefix from filename
file_stripped=${file#"${DIR_PREFIX}"}
# blob status is deleted
if [[ "$status" == "D" ]]; then
echo "deleting ${file_stripped}"
sed -i "\%^${file_stripped}%d" "${MY_DIR}/proprietary-files.txt"
continue
fi
# generate sha1 # generate sha1
r="$(sha1sum "$file")" r="$(sha1sum "$file")"
r_arr=($r) r_arr=($r)
sha1="${r_arr[0]}" sha1="${r_arr[0]}"
# remove directory prefix from filename # blob is newly added
file_stripped=${file#"${DIR_PREFIX}"} if [[ "$status" == "A" ]]; then
echo "adding ${file_stripped}"
echo "${file_stripped}|${sha1}" >> "${MY_DIR}/proprietary-files.txt"
continue
fi
# the rest files already exist in the list and are modified
# iterate through lines in proprietary-files.txt until the first # iterate through lines in proprietary-files.txt until the first
# non-comment match # non-comment match
for line in $(grep "$file_stripped" "${MY_DIR}/proprietary-files.txt") for line in $(grep "$file_stripped" "${MY_DIR}/proprietary-files.txt")