Scriptrunner: pre hook for detecting if commit is a merge commit from a pull request

Hello, I want to create a pre hook in scriptrunner with the following functionality.

  1. Detect if the commit is from a PR, then the pre hook always passes.
  2. If it is not from a PR merge commit I want to check if there are not any changes to specific folders.

I have trouble with implementing the first part. I know there is functionality for this under merge checks, but is this also possible for pre hooks?

Thank you in advance, any help or advice is welcome.