Skip to content

Commit e2e0339

Browse files
committed
ci: reject feature/fix branches that target main directly
A feature/fix branch merges into a release or maintenance branch; only release/* merges into main. Opening a second PR at main from the same branch is a duplicate, and it also breaks the changelog fragment, which is numbered for exactly one PR. This pattern already cost a wasted PR in six repositories (a ->release PR merged alongside a ->main PR that was then closed), and the fragment numbering check only exposed it indirectly, by failing the leftover PR. hotfix/* -> main stays allowed; the version control policy calls for hotfixes to be merged back to main and the active release branch.
1 parent 4bbc17e commit e2e0339

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎.github/workflows/changelog-check.yml‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Enforces the rhosocial changelog fragment rules.
44
#
55
# feature/* or fix/* -> release/* | maint/*| main
6+
# - a feature/fix branch must not target main directly
67
# - the PR must add at least one changelog.d/<number>.<type>.md fragment
78
# - every added fragment's <number> must equal the PR number
89
# - fragments already present in changelog.d/ from previously merged
@@ -167,6 +168,28 @@ jobs:
167168
exit 0
168169
fi
169170
171+
# A feature/fix branch never merges straight into main; it targets a
172+
# release or maintenance branch. Opening a second PR at main from the
173+
# same branch is a duplicate, and it also invalidates the fragment
174+
# numbering, which is bound to a single PR number.
175+
if [[ ("$HEAD_REF" == feature/* || "$HEAD_REF" == fix/* || "$HEAD_REF" == bugfix/* \
176+
|| "$HEAD_REF" == test/* || "$HEAD_REF" == docs/* || "$HEAD_REF" == chore/*) \
177+
&& "$BASE_REF" == "main" ]]; then
178+
echo "::error::'$HEAD_REF' must not target \`main\` directly."
179+
echo ""
180+
echo "Per the rhosocial merge rules:"
181+
echo " feature/* fix/* bugfix/* test/* docs/* chore/* -> release/* | maint/*"
182+
echo " release/* -> main"
183+
echo ""
184+
echo "Retarget this PR at the active release branch, or close it if"
185+
echo "another PR from '$HEAD_REF' already targets the release branch."
186+
echo "The changelog fragment is numbered for one PR only, so a duplicate"
187+
echo "PR at main would also fail the fragment numbering check."
188+
echo ""
189+
git branch -r --list "origin/release/*" | sed 's#.*origin/##' | sed 's/^/ /'
190+
exit 1
191+
fi
192+
170193
git fetch origin "$BASE_REF" --quiet
171194
172195
# Fragments ADDED by this PR. Fragments that were already in

0 commit comments

Comments
 (0)