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