Skip to content

Commit 24040c1

Browse files
authored
Add some logic to prevent #982 from happening again (#1022)
Ensure that - v2.1-wip branch is up to date from v2.0 before merging any PR - v3.0-wip branch is up to date from v2.1-wip before merging any PR
1 parent f55ad32 commit 24040c1

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Block PRs targeting wip branches (v2.1-wip, v3.0-wip) when they are
2+
# behind their parent branch (v2.0 and v2.1-wip respectively).
3+
# This prevents unpropagated commits from accumulating, which leads to
4+
# costly backports of many commits generating large conflicts.
5+
# See https://github.com/TransmodelEcosystem/NeTEx/issues/982
6+
7+
name: Check parent branch is up to date
8+
9+
on:
10+
pull_request:
11+
branches: [v2.1-wip, v3.0-wip]
12+
13+
jobs:
14+
parent-branch-is-up-to-date:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Verify base branch contains all parent commits
22+
run: |
23+
case "${{ github.base_ref }}" in
24+
v2.1-wip) parent=v2.0 ;;
25+
v3.0-wip) parent=v2.1-wip ;;
26+
esac
27+
28+
behind=$(git rev-list --count "origin/${{ github.base_ref }}..origin/$parent")
29+
if [ "$behind" -gt 0 ]; then
30+
echo "::error::${{ github.base_ref }} is $behind commit(s) behind $parent. Merge $parent into ${{ github.base_ref }} first."
31+
git log --oneline "origin/${{ github.base_ref }}..origin/$parent"
32+
exit 1
33+
fi

0 commit comments

Comments
 (0)