Commit 68e4d865 authored by Illya Klymov's avatar Illya Klymov Committed by Mike Greiling

Enforce .git in the URL when importing Repo by URL

parent 8cd819af
......@@ -83,7 +83,7 @@
.js-toggle-content.toggle-import-form{ class: ('hide' if active_tab != 'import') }
= form_for @project, html: { class: 'new_project' } do |f|
= form_for @project, html: { class: 'new_project gl-show-field-errors' } do |f|
%hr
= render "shared/import_form", f: f
= render 'projects/new_project_fields', f: f, project_name_id: "import-url-name", hide_init_with_readme: true, track_label: track_label
......@@ -6,8 +6,14 @@
= f.label :import_url, class: 'label-bold' do
%span
= _('Git repository URL')
= f.text_field :import_url, value: import_url.sanitized_url,
autocomplete: 'off', class: 'form-control gl-form-input', placeholder: 'https://gitlab.company.com/group/project.git', required: true
= f.text_field :import_url,
value: import_url.sanitized_url,
autocomplete: 'off',
class: 'form-control gl-form-input',
placeholder: 'https://gitlab.company.com/group/project.git',
required: true,
pattern: '(?:git|https?):\/\/.*/.*\.git$',
title: _('Please provide a valid URL ending with .git')
.row
.form-group.col-md-6
......
---
title: Enforce .git suffix when importing git repo
merge_request: 61115
author:
type: changed
......@@ -74,7 +74,7 @@ RSpec.describe 'New project', :js do
page.within '#import-project-pane' do
first('.js-import-git-toggle-button').click
fill_in 'project_import_url', with: 'http://foo.git'
fill_in 'project_import_url', with: 'http://foo/bar.git'
fill_in 'project_name', with: 'import-project-with-features1'
fill_in 'project_path', with: 'import-project-with-features1'
choose 'project_visibility_level_20'
......@@ -94,7 +94,7 @@ RSpec.describe 'New project', :js do
page.within '#ci-cd-project-pane' do
find('.js-import-git-toggle-button').click
fill_in 'project_import_url', with: 'http://foo.git'
fill_in 'project_import_url', with: 'http://foo/bar.git'
fill_in 'project_name', with: 'CI CD Project1'
fill_in 'project_path', with: 'ci-cd-project1'
choose 'project_visibility_level_20'
......
......@@ -24322,6 +24322,9 @@ msgstr ""
msgid "Please provide a valid URL"
msgstr ""
msgid "Please provide a valid URL ending with .git"
msgstr ""
msgid "Please provide a valid YouTube URL or ID"
msgstr ""
......
......@@ -355,6 +355,16 @@ RSpec.describe 'New project', :js do
expect(git_import_instructions).to have_content 'Git repository URL'
end
it 'reports error if repo URL does not end with .git' do
fill_in 'project_import_url', with: 'http://foo/bar'
fill_in 'project_name', with: 'import-project-without-git-suffix'
fill_in 'project_path', with: 'import-project-without-git-suffix'
click_button 'Create project'
expect(page).to have_text('Please provide a valid URL ending with .git')
end
it 'keeps "Import project" tab open after form validation error' do
collision_project = create(:project, name: 'test-name-collision', namespace: user.namespace)
......
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