finally fixed the permissions thingamagic for the shit script
All checks were successful
Update Child Repos / update (push) Successful in 5s

This commit is contained in:
2026-01-02 15:07:02 +01:00
parent f306f887a8
commit 75769dcff6

View File

@@ -18,29 +18,20 @@ PREVIOUS_COMMIT_ID=$(git log --format="%H" -n 2 HEAD | tail -n 1)
if [ "${PREVIOUS_COMMIT_ID}" = "${CURRENT_COMMIT_ID}" ]; then
FILES_CHANGED=""
FILES_PERMISSION_CHANGED=""
else
FILES_CHANGED=$(git diff --name-only "${PREVIOUS_COMMIT_ID}" "${CURRENT_COMMIT_ID}" | tr '\n' ' ')
FILES_PERMISSION_CHANGED=$(git diff --summary "${PREVIOUS_COMMIT_ID}" "${CURRENT_COMMIT_ID}" | (grep "mode change" || true) | sed -E 's/.*mode change [0-9]+ => [0-9]+ (.*)/\1/' | tr '\n' ' ')
fi
is_file_changed() {
local file_to_check="$1"
if [ -z "${FILES_CHANGED}" ] && [ -z "${FILES_PERMISSION_CHANGED}" ]; then
if [ -z "${FILES_CHANGED}" ]; then
return 1
fi
for changed_file in ${FILES_CHANGED}; do
if [ "${changed_file}" = "${file_to_check}" ]; then
return 0
fi
done
for changed_file in ${FILES_PERMISSION_CHANGED}; do
if [ "${changed_file}" = "${file_to_check}" ]; then
return 0
fi
done
return 1
}
@@ -109,8 +100,10 @@ while IFS= read -r clone_url; do
if [ -f "${file}" ]; then
current_content=$(cat "${file}" 2>/dev/null || true)
current_permissions=$(stat -c "%a" "${file}" 2>/dev/null || echo "644")
template_permissions=$(pushd "${TEMPLATE_REPO_DIR}" >/dev/null && stat -c "%a" "${file}" 2>/dev/null || echo "644" && popd >/dev/null)
if [ "${current_content}" = "${template_content}" ]; then
if [ "${current_content}" = "${template_content}" ] && [ "${current_permissions}" = "${template_permissions}" ]; then
continue
fi
@@ -127,9 +120,7 @@ while IFS= read -r clone_url; do
patched_content=$(cat "${tmp_current}")
if [ "${current_content}" != "${patched_content}" ]; then
template_permissions=$(pushd "${TEMPLATE_REPO_DIR}" >/dev/null && stat -c "%a" "${file}" 2>/dev/null || echo "644" && popd >/dev/null)
echo "${patched_content}" > "${file}"
chmod "${template_permissions}" "${file}" 2>/dev/null || true
git add "${file}"
files_changed=true
echo "Merged updates for ${file} in ${repo_name}"
@@ -144,6 +135,15 @@ while IFS= read -r clone_url; do
echo "File ${file} has local changes in ${repo_name} - preserving local changes"
conflicted_files+=("${file}")
fi
template_permissions=$(pushd "${TEMPLATE_REPO_DIR}" >/dev/null && stat -c "%a" "${file}" 2>/dev/null || echo "644" && popd >/dev/null)
current_permissions=$(stat -c "%a" "${file}" 2>/dev/null || echo "644")
if [ "${current_permissions}" != "${template_permissions}" ]; then
chmod "${template_permissions}" "${file}" 2>/dev/null || true
git add "${file}"
files_changed=true
echo "Updated permissions for ${file} in ${repo_name}"
fi
else
echo "Adding new file ${file} from template to ${repo_name}"
mkdir -p "$(dirname "${file}")"