From e05643058e3f0f161db19498366defc5cc0ca4c3 Mon Sep 17 00:00:00 2001 From: Felix Kaschura Date: Wed, 17 Jul 2024 18:19:26 +0200 Subject: [PATCH] Use source commit hash instead of branch name to support PRs from forks --- .github/Check-SemilinearHistory.ps1 | 5 ++--- .github/workflows/semilinear_history.yml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/Check-SemilinearHistory.ps1 b/.github/Check-SemilinearHistory.ps1 index f7b55e9e..c65b74cc 100644 --- a/.github/Check-SemilinearHistory.ps1 +++ b/.github/Check-SemilinearHistory.ps1 @@ -2,15 +2,14 @@ Param( [Parameter(Mandatory)] [string]$targetBranch, [Parameter(Mandatory)] - [string]$sourceBranch + [string]$commitSource ) $ErrorActionPreference = 'Stop' git fetch origin $targetBranch $commitTarget = git rev-parse "origin/$targetBranch" -git fetch origin $sourceBranch -$commitSource = git rev-parse "origin/$sourceBranch" +git fetch origin $commitSource # verify that source branch originates from the latest commit of the target branch # (i.e. a fast-forward merge could be performed) diff --git a/.github/workflows/semilinear_history.yml b/.github/workflows/semilinear_history.yml index d339be53..164a3505 100644 --- a/.github/workflows/semilinear_history.yml +++ b/.github/workflows/semilinear_history.yml @@ -16,4 +16,4 @@ jobs: - name: Check Semilinear History shell: pwsh run: | - .\.github\Check-SemilinearHistory.ps1 -targetBranch ${{ github.base_ref }} -sourceBranch ${{ github.head_ref }} + .\.github\Check-SemilinearHistory.ps1 -targetBranch ${{ github.base_ref }} -commitSource ${{ github.event.pull_request.head.sha }}