Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set protected file patterns for files that can not be changed under no conditions #10806

Merged
merged 2 commits into from
Mar 26, 2020

Conversation

lafriks
Copy link
Member

@lafriks lafriks commented Mar 23, 2020

When pattern is set files that match them can not be changed neither using PR, nor push or web editor.

This could be later in other PR probably improved with exceptions to allow changing in PR

Screenshots:
image

image

image

@lafriks lafriks added type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/changelog Adds the changelog for a new Gitea version labels Mar 23, 2020
@lafriks lafriks added this to the 1.12.0 milestone Mar 23, 2020
routers/private/hook.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 23, 2020
routers/private/hook.go Outdated Show resolved Hide resolved
@zeripath
Copy link
Contributor

I think those two warns are probably left over from testing.

@lafriks
Copy link
Member Author

lafriks commented Mar 23, 2020

Yes, for debugging ;)

@zeripath
Copy link
Contributor

I know exactly how you feel - some of my debugging log messages have actually managed to get into Gitea proper by mistake...

routers/private/hook.go Outdated Show resolved Hide resolved
models/branches.go Outdated Show resolved Hide resolved
options/locale/locale_en-US.ini Show resolved Hide resolved
routers/private/hook.go Show resolved Hide resolved
@davydov-vyacheslav
Copy link

@lafriks I'm appreciate your changes . Actually I also was looking for something like this. But, my 2 cents is whether locking mechanism (like gitlab has https://docs.gitlab.com/ee/user/project/file_lock.html ) is better or not your implementation?

From business logic the manager need to lock specific files, not by mask. And these files are already exists in repository (master branch?)

@lafriks
Copy link
Member Author

lafriks commented Mar 24, 2020

@davydov-vyacheslav you can add also specific files using mask. This is a bit different use case as file locking, file locking is more to lock temporary while this is more permanent

@lafriks
Copy link
Member Author

lafriks commented Mar 24, 2020

Also Gitea supports LFS file locking

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 26, 2020
… conditions

Co-Authored-By: zeripath <art27@cantab.net>
@codecov-io
Copy link

Codecov Report

Merging #10806 into master will decrease coverage by 0.04%.
The diff coverage is 9.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10806      +/-   ##
==========================================
- Coverage   43.56%   43.51%   -0.05%     
==========================================
  Files         589      590       +1     
  Lines       82691    82797     +106     
==========================================
+ Hits        36023    36028       +5     
- Misses      42192    42292     +100     
- Partials     4476     4477       +1     
Impacted Files Coverage Δ
models/error.go 28.32% <0.00%> (-0.40%) ⬇️
models/migrations/migrations.go 4.16% <ø> (ø)
models/migrations/v132.go 0.00% <0.00%> (ø)
modules/auth/repo_form.go 44.44% <ø> (ø)
modules/repofiles/delete.go 44.51% <0.00%> (-2.43%) ⬇️
modules/repofiles/update.go 38.11% <0.00%> (-0.59%) ⬇️
routers/private/hook.go 32.39% <1.78%> (-4.22%) ⬇️
models/branches.go 41.88% <45.45%> (+0.11%) ⬆️
modules/convert/convert.go 74.92% <100.00%> (+0.07%) ⬆️
routers/api/v1/repo/branch.go 50.09% <100.00%> (+0.36%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1c331c...f6a2483. Read the comment docs.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 26, 2020
@zeripath
Copy link
Contributor

(As an aside - my persistent warning applies here: we assume that git filenames are utf8 strings - there is no guarantee of this ... the only thing not actually allowed is \0)

@lafriks
Copy link
Member Author

lafriks commented Mar 26, 2020

Make lgtm work

@lafriks lafriks merged commit bbd910e into go-gitea:master Mar 26, 2020
@lafriks lafriks deleted the feat/branch_readonly_files branch March 26, 2020 22:26
@a1012112796
Copy link
Member

I think maybe we should allow repo admin to add commit to change protect files. No one can change it is not good idea, do you think so?Thanks.

@lafriks
Copy link
Member Author

lafriks commented Apr 27, 2020

That could be possibly added as option if needed

@zeripath
Copy link
Contributor

The only way that would work would be through a flag that the admin could set and unset as and when they needed to do it. There is no way to warn an admin that they were about to splat a protected file and ask them if they really meant to do that during a git push - you simply do not have interactivity like that.

@a1012112796
Copy link
Member

a1012112796 commented Apr 27, 2020

Another suggestion about this feature: maybe we should also check whether it changed protected files when making a pr to protected branch, if have. should block it to be merge. similar to checking whether have conflicting files

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
@delvh delvh removed the type/changelog Adds the changelog for a new Gitea version label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants