Gitlab Push rules reject regex commit

370 Views Asked by At

In Gitlab Push rules in "Require expression in commit messages" there is a regular expression:

^(feat|fix|perf|refactor|removed)(:\s)(HPA-\d+)(\s)(.+)

But when pushing a valid commit "feat: HPA-1234 Test" the commit is rejected.

When checked against regex101, the commit succeeds: https://regex101.com/r/hwwO1l/1

If we make a wider regular expression

^(feat|fix|perf|refactor|removed)(.*)

The commit is also rejected.

And if you explicitly specify a commit in the Push rules "feat: WPPA-3135 Test test" and try to push this commit, then the commit will also be rejected.

How can I check for what reason the commit does not pass the regular schedule?

1

There are 1 best solutions below

1
Michael On

It happened to us that we made multiple commits on that branch and with one of the commits the submit message did not match the required regex. It seems that all commits on a branch have to match the regex which is set in Gitlab.