try this
All checks were successful
Update Child Repos / update (push) Successful in 6s

This commit is contained in:
2026-01-02 08:54:54 +01:00
parent 743b56ca62
commit beefdf6849

View File

@@ -64,36 +64,56 @@ while IFS= read -r clone_url; do
if [ -n "${FILES_TO_UPDATE}" ]; then if [ -n "${FILES_TO_UPDATE}" ]; then
files_changed=false files_changed=false
conflicted_files=() conflicted_files=()
merge_base=$(git merge-base HEAD "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}" 2>/dev/null || true)
for file in ${FILES_TO_UPDATE}; do for file in ${FILES_TO_UPDATE}; do
if ! git show "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}:${file}" >/dev/null 2>&1; then if ! git show "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}:${file}" >/dev/null 2>&1; then
continue continue
fi fi
if [ -f "${file}" ] && [ -n "${merge_base}" ] && git show "${merge_base}:${file}" >/dev/null 2>&1; then template_content=$(git show "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}:${file}" 2>/dev/null || true)
if [ -f "${file}" ]; then
current_content=$(cat "${file}" 2>/dev/null || true)
if [ "${current_content}" = "${template_content}" ]; then
continue
fi
merge_base=$(git merge-base HEAD "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}" 2>/dev/null || true)
if [ -n "${merge_base}" ] && git show "${merge_base}:${file}" >/dev/null 2>&1; then
tmp_base=$(mktemp) tmp_base=$(mktemp)
tmp_template=$(mktemp) tmp_template=$(mktemp)
tmp_current=$(mktemp) tmp_current=$(mktemp)
git show "${merge_base}:${file}" > "${tmp_base}" 2>/dev/null
git show "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}:${file}" > "${tmp_template}" 2>/dev/null
cp "${file}" "${tmp_current}"
if git merge-file "${file}" "${tmp_base}" "${tmp_template}" 2>/dev/null; then git show "${merge_base}:${file}" > "${tmp_base}" 2>/dev/null
echo "${template_content}" > "${tmp_template}"
echo "${current_content}" > "${tmp_current}"
if git merge-file "${tmp_current}" "${tmp_base}" "${tmp_template}" 2>/dev/null; then
merged_content=$(cat "${tmp_current}")
if [ "${current_content}" != "${merged_content}" ]; then
echo "${merged_content}" > "${file}"
git add "${file}" git add "${file}"
files_changed=true files_changed=true
echo "Merged updates for ${file} in ${repo_name}"
fi
else else
echo "Conflict detected in ${repo_name}:${file}" echo "Merge conflict detected in ${repo_name}:${file} - preserving local changes"
conflicted_files+=("${file}") conflicted_files+=("${file}")
cp "${tmp_current}" "${file}"
git checkout HEAD -- "${file}" >/dev/null 2>&1 || true
fi fi
rm -f "${tmp_base}" "${tmp_template}" "${tmp_current}" rm -f "${tmp_base}" "${tmp_template}" "${tmp_current}"
else else
if git checkout "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}" -- "${file}" 2>/dev/null; then echo "No merge base available for ${file} in ${repo_name} - preserving local changes"
files_changed=true conflicted_files+=("${file}")
fi fi
else
echo "Adding new file ${file} from template to ${repo_name}"
mkdir -p "$(dirname "${file}")"
echo "${template_content}" > "${file}"
git add "${file}"
files_changed=true
fi fi
done done
@@ -107,6 +127,7 @@ while IFS= read -r clone_url; do
if ! git diff --cached --quiet; then if ! git diff --cached --quiet; then
git commit -m "${COMMIT_MESSAGE}" git commit -m "${COMMIT_MESSAGE}"
git push git push
echo "Pushed updates to ${repo_name}"
fi fi
fi fi
else else
@@ -153,7 +174,7 @@ if [ ${#REPOS_WITH_CONFLICTS[@]} -gt 0 ]; then
curl -s -X POST "${CONFLICT_WEBHOOK_URL}" \ curl -s -X POST "${CONFLICT_WEBHOOK_URL}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "${conflict_json}" >/dev/null 2>&1 || true -d "${conflict_json}" >/dev/null 2>&1 || true
fi fi
echo "" echo ""
echo "All repositories processed successfully!" echo "All repositories processed successfully!"