How to set limits for git commits/pushes?

Hi there

I’m sure this isn’t a github issue, but a question:

I’m setting up a gitea server with Postgres. I would like to set up limits for the size of files users can commit and push, 40MB. The app.ini has the following values:

[repository.upload]
; Whether repository file uploads are enabled. Defaults to `true`
ENABLED = true
; Path for uploads. Defaults to `data/tmp/uploads` (tmp gets deleted on gitea restart)
TEMP_PATH = data/tmp/uploads
; One or more allowed types, e.g. image/jpeg|image/png. Nothing means any file type
ALLOWED_TYPES =
; Max size of each file in megabytes. Defaults to 3MB
FILE_MAX_SIZE = 3
; Max number of files per upload. Defaults to 5
MAX_FILES = 5

I’ve set these values to be:

[repository.upload]
; Whether repository file uploads are enabled. Defaults to `true`
ENABLED = true
FILE_MAX_SIZE = 40

However, I’m still able to push and commit files several GB in size. I’ve restarted gitea, and have done make clean and make build several times.

I must be making a mistake: how do I set commit limits?

I think you need to do this via a pre-receive hook. For example… https://gist.github.com/nauar/826f85d25d692d9bc009312cb71577dd or https://stackoverflow.com/questions/39576257/how-to-limit-file-size-on-commit

Thanks @stu1811

Questions:
(1) How could I set this up on my own gitea server?

(2) So, what do the fields in [repository.upload] do?

In your gitea-repostories/My_Team/My_Repo.git/hooks create pre-receive and make it executable (chmod +x perceive). Paste in code.

I may be wrong but I think it’s for uploading content to reviews. Attachments are applicable to the Releases.

Thanks @stu1811

I guess I’m still a bit confused: how would this apply to all repos on the server?

Also, do you know how this could work with git lfs?

The hook is a per repo change.

I have not played with LFS. I imagine you can differentiate between the two but I haven’t done it.

Yes, it would be useful to have this for all github repos on the server.