Skip to content

Commit 305df3e

Browse files
Merge pull request #20 from alexphillips-dev/fix/main-history-guard-allows-pr-merges
Allow GitHub PR merges in main history guard
2 parents ec5e4c5 + da1420c commit 305df3e

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

scripts/main_branch_history_guard.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,18 @@ ensure_allowed_merge_refs() {
7272

7373
merge_commit_allowed() {
7474
local commit="${1:-}"
75+
local subject=""
7576
local parent_refs=""
7677
local parent_list=()
7778
local parent_index=0
7879
local parent_commit=""
7980
local allowed_ref=""
8081

82+
subject="$(git show -s --format=%s "${commit}" 2>/dev/null || true)"
83+
if [[ "${subject}" =~ ^Merge\ pull\ request\ #[0-9]+ ]]; then
84+
return 0
85+
fi
86+
8187
parent_refs="$(git show -s --format=%P "${commit}" 2>/dev/null || true)"
8288
if [[ -z "${parent_refs}" ]]; then
8389
return 1

tests/versioning-guard.test.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ test('standards guard scripts exist with expected core checks', () => {
426426
assert.match(mainBranchHistoryGuard, /FVPLUS_MAIN_HISTORY_BASE_REF/);
427427
assert.match(mainBranchHistoryGuard, /@\{upstream\}\.\.HEAD/);
428428
assert.match(mainBranchHistoryGuard, /merge_commit_allowed/);
429+
assert.match(mainBranchHistoryGuard, /Merge\\ pull\\ request\\ #\[0-9\]\+/);
429430
assert.match(mainBranchHistoryGuard, /main-branch merge commits must promote only dev\/beta history/);
430431
assert.match(mainBranchHistoryGuard, /Main branch history guard passed/);
431432
assert.match(unraidMatrixSmoke, /FVPLUS_UNRAID_MATRIX/);

0 commit comments

Comments
 (0)