Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5da06598
Commit
5da06598
authored
Jan 04, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add push rule regex examples to the API
parent
ce106e93
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
13 deletions
+20
-13
doc/api/projects.md
doc/api/projects.md
+13
-6
lib/api/project_push_rule.rb
lib/api/project_push_rule.rb
+1
-1
spec/requests/api/project_push_rule_spec.rb
spec/requests/api/project_push_rule_spec.rb
+6
-6
No files found.
doc/api/projects.md
View file @
5da06598
...
@@ -1454,9 +1454,9 @@ Parameters:
...
@@ -1454,9 +1454,9 @@ Parameters:
|
`deny_delete_tag`
| boolean | no | Deny deleting a tag |
|
`deny_delete_tag`
| boolean | no | Deny deleting a tag |
|
`member_check`
| boolean | no | Restrict commits by author (email) to existing GitLab users |
|
`member_check`
| boolean | no | Restrict commits by author (email) to existing GitLab users |
|
`prevent_secrets`
| boolean | no | GitLab will reject any files that are likely to contain secrets |
|
`prevent_secrets`
| boolean | no | GitLab will reject any files that are likely to contain secrets |
|
`commit_message_regex`
| string | no | All commit messages must match this |
|
`commit_message_regex`
| string | no | All commit messages must match this
, e.g.
`Fixed \d+\..*`
|
|
`author_email_regex`
| string | no | All commit author
's email must match this
|
|
`author_email_regex`
| string | no | All commit author
emails must match this, e.g.
`@my-company.com$`
|
|
`file_name_regex`
| string | no | All commited filenames must
**not**
match this |
|
`file_name_regex`
| string | no | All commited filenames must
**not**
match this
, e.g.
`(jar|exe)$`
|
|
`max_file_size`
| integer | no | Maximum file size (MB) |
|
`max_file_size`
| integer | no | Maximum file size (MB) |
### Edit project push rule
### Edit project push rule
...
@@ -1469,9 +1469,16 @@ PUT /projects/:id/push_rule
...
@@ -1469,9 +1469,16 @@ PUT /projects/:id/push_rule
Parameters:
Parameters:
-
`id`
(required) - The ID of a project
| Attribute | Type | Required | Description |
-
`deny_delete_tag`
- Do not allow users to remove git tags with git push
| --------- | ---- | -------- | ----------- |
-
`commit_message_regex`
- Commit message regex
|
`id`
| integer/string | yes | The ID of the project or NAMESPACE/PROJECT_NAME |
|
`deny_delete_tag`
| boolean | no | Deny deleting a tag |
|
`member_check`
| boolean | no | Restrict commits by author (email) to existing GitLab users |
|
`prevent_secrets`
| boolean | no | GitLab will reject any files that are likely to contain secrets |
|
`commit_message_regex`
| string | no | All commit messages must match this, e.g.
`Fixed \d+\..*`
|
|
`author_email_regex`
| string | no | All commit author emails must match this, e.g.
`@my-company.com$`
|
|
`file_name_regex`
| string | no | All commited filenames must
**not**
match this, e.g.
`(jar|exe)$`
|
|
`max_file_size`
| integer | no | Maximum file size (MB) |
### Delete project push rule
### Delete project push rule
...
...
lib/api/project_push_rule.rb
View file @
5da06598
...
@@ -13,7 +13,7 @@ module API
...
@@ -13,7 +13,7 @@ module API
optional
:member_check
,
type:
Boolean
,
desc:
'Restrict commits by author (email) to existing GitLab users'
optional
:member_check
,
type:
Boolean
,
desc:
'Restrict commits by author (email) to existing GitLab users'
optional
:prevent_secrets
,
type:
Boolean
,
desc:
'GitLab will reject any files that are likely to contain secrets'
optional
:prevent_secrets
,
type:
Boolean
,
desc:
'GitLab will reject any files that are likely to contain secrets'
optional
:commit_message_regex
,
type:
String
,
desc:
'All commit messages must match this'
optional
:commit_message_regex
,
type:
String
,
desc:
'All commit messages must match this'
optional
:author_email_regex
,
type:
String
,
desc:
"All commit author's email must match this"
optional
:author_email_regex
,
type:
String
,
desc:
'All commit author emails must match this'
optional
:file_name_regex
,
type:
String
,
desc:
'All commited filenames must not match this'
optional
:file_name_regex
,
type:
String
,
desc:
'All commited filenames must not match this'
optional
:max_file_size
,
type:
Integer
,
desc:
'Maximum file size (MB)'
optional
:max_file_size
,
type:
Integer
,
desc:
'Maximum file size (MB)'
at_least_one_of
:deny_delete_tag
,
:member_check
,
:prevent_secrets
,
at_least_one_of
:deny_delete_tag
,
:member_check
,
:prevent_secrets
,
...
...
spec/requests/api/project_push_rule_spec.rb
View file @
5da06598
...
@@ -40,9 +40,9 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
...
@@ -40,9 +40,9 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it
"adds push rule to project"
do
it
"adds push rule to project"
do
post
api
(
"/projects/
#{
project
.
id
}
/push_rule"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/push_rule"
,
user
),
deny_delete_tag:
true
,
member_check:
true
,
prevent_secrets:
true
,
deny_delete_tag:
true
,
member_check:
true
,
prevent_secrets:
true
,
commit_message_regex:
'
/JIRA\-\d+/
'
,
commit_message_regex:
'
JIRA\-\d+
'
,
author_email_regex:
'
/[a-zA-Z0-9]+@gitlab.com/
'
,
author_email_regex:
'
[a-zA-Z0-9]+@gitlab.com
'
,
file_name_regex:
'
/[a-zA-Z0-9]+.key/
'
,
file_name_regex:
'
[a-zA-Z0-9]+.key
'
,
max_file_size:
5
max_file_size:
5
expect
(
response
).
to
have_http_status
(
201
)
expect
(
response
).
to
have_http_status
(
201
)
...
@@ -50,9 +50,9 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
...
@@ -50,9 +50,9 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
expect
(
json_response
[
'deny_delete_tag'
]).
to
eq
(
true
)
expect
(
json_response
[
'deny_delete_tag'
]).
to
eq
(
true
)
expect
(
json_response
[
'member_check'
]).
to
eq
(
true
)
expect
(
json_response
[
'member_check'
]).
to
eq
(
true
)
expect
(
json_response
[
'prevent_secrets'
]).
to
eq
(
true
)
expect
(
json_response
[
'prevent_secrets'
]).
to
eq
(
true
)
expect
(
json_response
[
'commit_message_regex'
]).
to
eq
(
'
/JIRA\-\d+/
'
)
expect
(
json_response
[
'commit_message_regex'
]).
to
eq
(
'
JIRA\-\d+
'
)
expect
(
json_response
[
'author_email_regex'
]).
to
eq
(
'
/[a-zA-Z0-9]+@gitlab.com/
'
)
expect
(
json_response
[
'author_email_regex'
]).
to
eq
(
'
[a-zA-Z0-9]+@gitlab.com
'
)
expect
(
json_response
[
'file_name_regex'
]).
to
eq
(
'
/[a-zA-Z0-9]+.key/
'
)
expect
(
json_response
[
'file_name_regex'
]).
to
eq
(
'
[a-zA-Z0-9]+.key
'
)
expect
(
json_response
[
'max_file_size'
]).
to
eq
(
5
)
expect
(
json_response
[
'max_file_size'
]).
to
eq
(
5
)
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment