Commit 5da06598 authored by Robert Schilling's avatar Robert Schilling

Add push rule regex examples to the API

parent ce106e93
...@@ -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
......
...@@ -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,
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment