Skip to content

Commit 7b4b2d1

Browse files
Fix main CI history checkout and release-only backmerge
1 parent 56a3294 commit 7b4b2d1

2 files changed

Lines changed: 40 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
1820

1921
- name: Setup Node
2022
uses: actions/setup-node@v4

scripts/sync_main_to_dev.sh

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ DEV_REF="origin/dev"
1010

1111
git fetch origin main dev --tags
1212

13+
release_only_path() {
14+
local path="${1:-}"
15+
case "${path}" in
16+
folderview.plus.plg|archive/folderview.plus-*.txz|archive/folderview.plus-*.txz.sha256)
17+
return 0
18+
;;
19+
*)
20+
return 1
21+
;;
22+
esac
23+
}
24+
25+
main_differs_from_dev_only_by_release_artifacts() {
26+
local path=""
27+
mapfile -t DIFF_PATHS < <(git diff --name-only "${DEV_REF}..${MAIN_REF}" || true)
28+
if [ "${#DIFF_PATHS[@]}" -eq 0 ]; then
29+
return 1
30+
fi
31+
for path in "${DIFF_PATHS[@]}"; do
32+
if ! release_only_path "${path}"; then
33+
return 1
34+
fi
35+
done
36+
return 0
37+
}
38+
1339
if git show-ref --verify --quiet "refs/heads/${DEV_BRANCH}"; then
1440
git checkout "${DEV_BRANCH}"
1541
else
@@ -21,6 +47,11 @@ if git merge-base --is-ancestor "${MAIN_REF}" "${DEV_BRANCH}"; then
2147
exit 0
2248
fi
2349

50+
if main_differs_from_dev_only_by_release_artifacts; then
51+
echo "Main differs from dev only by release artifacts/manifest. Skipping back-merge."
52+
exit 0
53+
fi
54+
2455
MERGED_CLEANLY=1
2556
if ! git merge --no-ff --no-commit "${MAIN_REF}"; then
2657
MERGED_CLEANLY=0
@@ -35,21 +66,15 @@ if [ "${MERGED_CLEANLY}" -eq 0 ]; then
3566
fi
3667

3768
for FILE in "${CONFLICTS[@]}"; do
38-
case "${FILE}" in
39-
folderview.plus.plg|archive/folderview.plus-*.txz|archive/folderview.plus-*.txz.sha256)
40-
;;
41-
*)
42-
echo "Unexpected merge conflict in ${FILE}; aborting auto back-merge." >&2
43-
git merge --abort
44-
exit 1
45-
;;
46-
esac
69+
if ! release_only_path "${FILE}"; then
70+
echo "Unexpected merge conflict in ${FILE}; aborting auto back-merge." >&2
71+
git merge --abort
72+
exit 1
73+
fi
4774
done
4875

49-
for FILE in "${CONFLICTS[@]}"; do
50-
git checkout --ours -- "${FILE}"
51-
git add "${FILE}"
52-
done
76+
git checkout HEAD -- archive folderview.plus.plg
77+
git add archive folderview.plus.plg
5378
fi
5479

5580
# Always force dev channel URLs in case main touched these lines without conflicts.
@@ -67,4 +92,3 @@ if git rev-parse -q --verify MERGE_HEAD >/dev/null; then
6792
else
6893
echo "No merge head present; nothing to commit."
6994
fi
70-

0 commit comments

Comments
 (0)