diff --git a/update_child_repos.sh b/update_child_repos.sh index 5932f00..bfdaea8 100755 --- a/update_child_repos.sh +++ b/update_child_repos.sh @@ -107,7 +107,7 @@ while IFS= read -r clone_url; do fi file_diff=$(git diff "${PREVIOUS_COMMIT_ID}" "${CURRENT_COMMIT_ID}" -- "${file}" 2>/dev/null || true) - + if [ -n "${file_diff}" ]; then tmp_current=$(mktemp) tmp_diff=$(mktemp) @@ -117,9 +117,11 @@ while IFS= read -r clone_url; do if patch --dry-run "${tmp_current}" "${tmp_diff}" >/dev/null 2>&1; then patch "${tmp_current}" "${tmp_diff}" >/dev/null 2>&1 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}" @@ -138,6 +140,8 @@ while IFS= read -r clone_url; do echo "Adding new file ${file} from template to ${repo_name}" mkdir -p "$(dirname "${file}")" echo "${template_content}" > "${file}" + template_permissions=$(pushd "${TEMPLATE_REPO_DIR}" >/dev/null && stat -c "%a" "${file}" 2>/dev/null || echo "644" && popd >/dev/null) + chmod "${template_permissions}" "${file}" 2>/dev/null || true git add "${file}" files_changed=true fi