palantir/policy-bot

targets_branch "pattern" action lacks NOT (a OR b) ability.

Opened this issue · 1 comments

derac commented

Hi,

In the targets_branch section, the user can select a branch with regex using the pattern action. This uses the Go regex system which is linear, and so doesn't support negative lookaheads. This makes it impossible to say NOT (a OR b OR c).

It would be useful if this section had functionality similar to the title section, which has matches and not_matches functions.

Thanks,
Derek

This would also be very useful to us, we have a defined branching policy but once a rule fails to match it skips it entirely. It would be nice to be able to require elevated approvals for deviations from our standard processes.

For example this was an attempted rule restricting the source and target of a PR:

  - name: Task into parent branch
    if:
      targets_branch:
        pattern: "^(feature|amend|update|fix|refactor)/[a-z0-9._-]+$"
      from_branch:
        pattern: "^task/[a-z]{2}/[a-z0-9._-]+$"

If this was updated we could do something like:

  - name: Invalid child branch
    if:
      targets_branch:
        matches: "^(feature|amend|update|fix|refactor)/[a-z0-9._-]+$"
      from_branch:
        not_matches: "^task/[a-z]{2}/[a-z0-9._-]+$"

  - name: Invalid parent branch
    if:
      targets_branch:
        not_matches: "^(feature|amend|update|fix|refactor)/[a-z0-9._-]+$"
      from_branch:
        matches: "^task/[a-z]{2}/[a-z0-9._-]+$"