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

Merged
lafriks merged 2 commits from feat/branch_readonly_files into master 2020-03-26 22:26:35 +00:00
lafriks commented 2020-03-23 19:15:40 +00:00 (Migrated from github.com)

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

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](https://user-images.githubusercontent.com/165205/77354354-5b4d7880-6d4b-11ea-8b55-241246dcbb4d.png) ![image](https://user-images.githubusercontent.com/165205/77354373-656f7700-6d4b-11ea-8132-08a4aa821734.png) ![image](https://user-images.githubusercontent.com/165205/77354393-702a0c00-6d4b-11ea-8b8e-73381ae54efc.png)
zeripath reviewed 2020-03-23 19:40:24 +00:00
Contributor

I suspect you don't intend these to stick around...

I suspect you don't intend these to stick around... ```suggestion ```
zeripath reviewed 2020-03-23 19:41:41 +00:00
Contributor
```suggestion ```
zeripath reviewed 2020-03-23 20:00:08 +00:00
Contributor
	NewMigration("Add Branch Protection Protected Files Column", addBranchProtectionProtectedFilesColumn),
```suggestion NewMigration("Add Branch Protection Protected Files Column", addBranchProtectionProtectedFilesColumn), ```
zeripath reviewed 2020-03-23 20:02:02 +00:00
Contributor

This looks like the same code as in delete.go - I wonder if we could refactor. (Don't have to do it though.)

This looks like the same code as in delete.go - I wonder if we could refactor. (Don't have to do it though.)
zeripath reviewed 2020-03-23 20:07:09 +00:00
@ -41,6 +41,7 @@ type BranchProtection struct {
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
RequireSignedCommits bool `json:"require_signed_commits"`
ProtectedFilePatterns string `json:"protected_file_patterns"`
Contributor

Just a comment: Isn't this a little excessive? json.Marshal and Unmarshal would give most of these the same names anyway

Just a comment: Isn't this a little excessive? json.Marshal and Unmarshal would give most of these the same names anyway
zeripath reviewed 2020-03-23 20:08:31 +00:00
Contributor

why not use models.ErrProtectedFile here?

why not use models.ErrProtectedFile here?
lafriks (Migrated from github.com) reviewed 2020-03-23 20:16:14 +00:00
@ -41,6 +41,7 @@ type BranchProtection struct {
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
RequireSignedCommits bool `json:"require_signed_commits"`
ProtectedFilePatterns string `json:"protected_file_patterns"`
lafriks (Migrated from github.com) commented 2020-03-23 20:16:13 +00:00

No it would not. Default golang json serialization would create field protectedFilePatterns

No it would not. Default golang json serialization would create field `protectedFilePatterns`
lafriks (Migrated from github.com) reviewed 2020-03-23 20:17:25 +00:00
lafriks (Migrated from github.com) commented 2020-03-23 20:17:25 +00:00

I would rather keep it as it is to be consistent with previous checks that also duplicate. It should probably be refactored in other PR

I would rather keep it as it is to be consistent with previous checks that also duplicate. It should probably be refactored in other PR
guillep2k (Migrated from github.com) reviewed 2020-03-24 04:35:55 +00:00
guillep2k (Migrated from github.com) commented 2020-03-24 04:22:00 +00:00
func (protectBranch *ProtectedBranch) GetProtectedFilePatterns() []glob.Glob {
```suggestion func (protectBranch *ProtectedBranch) GetProtectedFilePatterns() []glob.Glob { ```
@ -1489,2 +1489,4 @@
settings.require_signed_commits = Require Signed Commits
settings.require_signed_commits_desc = Reject pushes to this branch if they are unsigned or unverifiable
settings.protect_protected_file_patterns = Protected file patterns (separated using semicolon ';'):
settings.protect_protected_file_patterns_desc = Protected files that are not allowed to be changed directly even if user has rights to add, edit or delete files in this branch. Multiple patterns can be separated using semicolon (';'). See <a href="https://godoc.org/github.com/gobwas/glob#Compile">github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>.
guillep2k (Migrated from github.com) commented 2020-03-24 04:28:54 +00:00
settings.protect_protected_file_patterns_desc = Protected files that are not allowed to be changed directly even if user has rights to add, edit or delete files in this branch. Multiple patterns can be separated using semicolon (';'). See <a href="https://godoc.org/github.com/gobwas/glob#Compile">github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>. Pattern matching is case insensitive.
```suggestion settings.protect_protected_file_patterns_desc = Protected files that are not allowed to be changed directly even if user has rights to add, edit or delete files in this branch. Multiple patterns can be separated using semicolon (';'). See <a href="https://godoc.org/github.com/gobwas/glob#Compile">github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>. Pattern matching is case insensitive. ```
@ -60,0 +94,4 @@
}
if err := scanner.Err(); err != nil {
return err
}
guillep2k (Migrated from github.com) commented 2020-03-24 04:34:01 +00:00

Is Unicode normalization required? (like composing diacritics). I don't think those are common in latin alphabet derived languages (they do exist, though), but I believe that others like Arabic and Sanscrit use them a lot.

Is Unicode normalization required? (like composing diacritics). I don't think those are common in latin alphabet derived languages (they do exist, though), but I believe that others like Arabic and Sanscrit use them a lot.
lafriks (Migrated from github.com) reviewed 2020-03-25 00:23:48 +00:00
@ -60,0 +94,4 @@
}
if err := scanner.Err(); err != nil {
return err
}
lafriks (Migrated from github.com) commented 2020-03-25 00:23:48 +00:00

I don't think it's needed as golang should handle that internally imho

I don't think it's needed as golang should handle that internally imho
guillep2k (Migrated from github.com) approved these changes 2020-03-26 01:00:48 +00:00
zeripath approved these changes 2020-03-26 19:24:46 +00:00
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/gitea#10806
No description provided.