Commit 8f1b2eb7 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'add-push-rules-to-project-export' into 'master'

[RUN AS-IF-FOSS] Adding push rules to exported project

See merge request gitlab-org/gitlab!46275
parents 1ccdc069 c1bc8ed7
---
title: Adding push rules to project exports
merge_request: 46275
author:
type: added
......@@ -33,5 +33,22 @@
"auto_fix_sast": false,
"auto_fix_coverage_fuzzing": false,
"auto_fix_api_fuzzing": false
},
"push_rule": {
"force_push_regex": "MustContain",
"delete_branch_regex": "MustContain",
"commit_message_regex": "MustContain",
"author_email_regex": "MustContain",
"file_name_regex": "MustContain",
"branch_name_regex": "MustContain",
"commit_message_negative_regex": "MustNotContain",
"max_file_size": 1,
"deny_delete_tag": true,
"member_check": true,
"is_sample": true,
"prevent_secrets": true,
"reject_unsigned_commits": true,
"commit_committer_check": true,
"regexp_uses_re2": true
}
}
{"force_push_regex":"MustContain","delete_branch_regex":"MustContain","commit_message_regex":"MustContain","author_email_regex":"MustContain","file_name_regex":"MustContain","branch_name_regex":"MustContain","commit_message_negative_regex":"MustNotContain","max_file_size":1,"deny_delete_tag":true,"member_check":true,"is_sample":true,"prevent_secrets":true,"reject_unsigned_commits":true,"commit_committer_check":true,"regexp_uses_re2":true}
......@@ -112,4 +112,24 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
expect(project.security_setting.auto_fix_container_scanning).to be_truthy
end
end
describe 'push_rules' do
let_it_be(:project) { create(:project, name: 'project', path: 'project') }
let(:user) { create(:user)}
before do
setup_import_export_config('complex', 'ee')
end
it 'creates push rules' do
project = Project.find_by_path('project')
expect { restored_project_json }.to change { PushRule.count }.from(0).to(1)
expect(project.push_rule.force_push_regex).to eq("MustContain")
expect(project.push_rule.commit_message_negative_regex).to eq("MustNotContain")
expect(project.push_rule.max_file_size).to eq(1)
expect(project.push_rule.deny_delete_tag).to be_truthy
end
end
end
......@@ -16,6 +16,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
let_it_be(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec_ee" }
let_it_be(:security_setting) { create(:project_security_setting, project: project, auto_fix_dast: false) }
let_it_be(:push_rule) { create(:push_rule, project: project, max_file_size: 10) }
after :all do
FileUtils.rm_rf(export_path)
......@@ -78,6 +79,18 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
expect(security_json['auto_fix_dependency_scanning']).to be_truthy
end
end
context 'push_rule' do
let(:push_rule_json) do
json = get_json(full_path, exportable_path, :push_rule, ndjson_enabled)
ndjson_enabled ? json.first : json
end
it 'has push rules' do
expect(push_rule_json['max_file_size']).to eq(10)
expect(push_rule_json['force_push_regex']).to eq('feature\/.*')
end
end
end
context 'with JSON' do
......
......@@ -411,8 +411,25 @@ ee:
- :deploy_access_levels
- :service_desk_setting
- :security_setting
- :push_rule
included_attributes:
issuable_sla:
- :issue
- :due_at
push_rule:
- :force_push_regex
- :delete_branch_regex
- :commit_message_regex
- :author_email_regex
- :file_name_regex
- :branch_name_regex
- :commit_message_negative_regex
- :max_file_size
- :deny_delete_tag
- :member_check
- :is_sample
- :prevent_secrets
- :reject_unsigned_commits
- :commit_committer_check
- :regexp_uses_re2
......@@ -7211,5 +7211,23 @@
}
]
}
]
],
"push_rule": {
"force_push_regex": "MustContain",
"delete_branch_regex": "MustContain",
"commit_message_regex": "MustContain",
"author_email_regex": "MustContain",
"file_name_regex": "MustContain",
"branch_name_regex": "MustContain",
"commit_message_negative_regex": "MustNotContain",
"max_file_size": 1,
"deny_delete_tag": true,
"member_check": true,
"is_sample": true,
"prevent_secrets": true,
"reject_unsigned_commits": true,
"commit_committer_check": true,
"regexp_uses_re2": true
}
}
......@@ -858,3 +858,19 @@ ProjectSecuritySetting:
IssuableSla:
- issue_id
- due_at
PushRule:
- force_push_regex
- delete_branch_regex
- commit_message_regex
- author_email_regex
- file_name_regex
- branch_name_regex
- commit_message_negative_regex
- max_file_size
- deny_delete_tag
- member_check
- is_sample
- prevent_secrets
- reject_unsigned_commits
- commit_committer_check
- regexp_uses_re2
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