Support displaying custom message when rejecting blacklisted file names
Description
GitLab has support for prohibited file names, where one can provide a pattern to reject pushes containing files matching the pattern.
When a push gets rejected it looks as follows:
tdevelioglu@traveler:~/workspace/bar$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 280 bytes | 280.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: GitLab: File name qux_2018-01-22T14:37:43+0100.txt was blacklisted by the pattern /<|>|:|"|\/|\||\?|\*/.
To remote.example.com:foo/bar.git
! [remote rejected] tdevelioglu -> tdevelioglu (pre-receive hook declined)
error: failed to push some refs to 'git@remote.example.com:foo/bar.git'
The rejection message shows the file and the pattern that caused the rejection.
While this is enough for the user to figure out what part of his push triggered the rejection (if he knows regular expressions), it can still leave him confused and guessing towards the actual motivation behind the rejection.
In this example it rejects forbidden characters in filenames on Windows but the confusion gets amplified if the prohibited filename doesn't have a clear technical reason but rather a business or historical-technical reason.
Proposal
- support showing a custom message when a push is rejected because of a blacklisted file name
Possible further improvement: support for multiple patterns, each with its own message, would be ideal.