Commit 75286ed4 authored by Mike Greiling's avatar Mike Greiling

Merge branch '276953-enforce-git-in-the-url-when-importing-repo-by-url' into 'master'

Enforce .git in the URL when importing Repo by URL

See merge request gitlab-org/gitlab!61115
parents c804992d 68e4d865
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
.js-toggle-content.toggle-import-form{ class: ('hide' if active_tab != 'import') } .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 %hr
= render "shared/import_form", f: f = 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 = 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 @@ ...@@ -6,8 +6,14 @@
= f.label :import_url, class: 'label-bold' do = f.label :import_url, class: 'label-bold' do
%span %span
= _('Git repository URL') = _('Git repository URL')
= f.text_field :import_url, value: import_url.sanitized_url, = f.text_field :import_url,
autocomplete: 'off', class: 'form-control gl-form-input', placeholder: 'https://gitlab.company.com/group/project.git', required: true 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 .row
.form-group.col-md-6 .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 ...@@ -74,7 +74,7 @@ RSpec.describe 'New project', :js do
page.within '#import-project-pane' do page.within '#import-project-pane' do
first('.js-import-git-toggle-button').click 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_name', with: 'import-project-with-features1'
fill_in 'project_path', with: 'import-project-with-features1' fill_in 'project_path', with: 'import-project-with-features1'
choose 'project_visibility_level_20' choose 'project_visibility_level_20'
...@@ -94,7 +94,7 @@ RSpec.describe 'New project', :js do ...@@ -94,7 +94,7 @@ RSpec.describe 'New project', :js do
page.within '#ci-cd-project-pane' do page.within '#ci-cd-project-pane' do
find('.js-import-git-toggle-button').click 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_name', with: 'CI CD Project1'
fill_in 'project_path', with: 'ci-cd-project1' fill_in 'project_path', with: 'ci-cd-project1'
choose 'project_visibility_level_20' choose 'project_visibility_level_20'
......
...@@ -24322,6 +24322,9 @@ msgstr "" ...@@ -24322,6 +24322,9 @@ msgstr ""
msgid "Please provide a valid URL" msgid "Please provide a valid URL"
msgstr "" msgstr ""
msgid "Please provide a valid URL ending with .git"
msgstr ""
msgid "Please provide a valid YouTube URL or ID" msgid "Please provide a valid YouTube URL or ID"
msgstr "" msgstr ""
......
...@@ -355,6 +355,16 @@ RSpec.describe 'New project', :js do ...@@ -355,6 +355,16 @@ RSpec.describe 'New project', :js do
expect(git_import_instructions).to have_content 'Git repository URL' expect(git_import_instructions).to have_content 'Git repository URL'
end 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 it 'keeps "Import project" tab open after form validation error' do
collision_project = create(:project, name: 'test-name-collision', namespace: user.namespace) 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