Skip to content
Snippets Groups Projects
Commit 8039b9c3 authored by Douwe Maan's avatar Douwe Maan
Browse files

Merge branch '30410-revert-9347-and-10079' into 'master'

Resolve "Allow to disable username on checkout url"

Closes #30410 and #30174

See merge request !11792
parents c5e26e57 08134ad2
No related branches found
No related tags found
No related merge requests found
Showing with 26 additions and 63 deletions
Loading
Loading
@@ -56,7 +56,7 @@ module ButtonHelper
 
content_tag (append_link ? :a : :span), protocol,
class: klass,
href: (project.http_url_to_repo(current_user) if append_link),
href: (project.http_url_to_repo if append_link),
data: {
html: true,
placement: placement,
Loading
Loading
Loading
Loading
@@ -276,7 +276,7 @@ module ProjectsHelper
when 'ssh'
project.ssh_url_to_repo
else
project.http_url_to_repo(current_user)
project.http_url_to_repo
end
end
 
Loading
Loading
Loading
Loading
@@ -874,10 +874,8 @@ class Project < ActiveRecord::Base
url_to_repo
end
 
def http_url_to_repo(user = nil)
credentials = Gitlab::UrlSanitizer.http_credentials_for_user(user)
Gitlab::UrlSanitizer.new("#{web_url}.git", credentials: credentials).full_url
def http_url_to_repo
"#{web_url}.git"
end
 
def user_can_push_to_empty_repo?(user)
Loading
Loading
Loading
Loading
@@ -42,11 +42,8 @@ class ProjectWiki
url_to_repo
end
 
def http_url_to_repo(user = nil)
url = "#{Gitlab.config.gitlab.url}/#{path_with_namespace}.git"
credentials = Gitlab::UrlSanitizer.http_credentials_for_user(user)
Gitlab::UrlSanitizer.new(url, credentials: credentials).full_url
def http_url_to_repo
"#{Gitlab.config.gitlab.url}/#{path_with_namespace}.git"
end
 
def wiki_base_path
Loading
Loading
---
title: Revert the feature that would include the current user's username in the HTTP
clone URL
merge_request: 11792
author:
Loading
Loading
@@ -49,7 +49,7 @@ class Spinach::Features::ExploreProjects < Spinach::FeatureSteps
 
step 'I should see an http link to the repository' do
project = Project.find_by(name: 'Community')
expect(page).to have_field('project_clone', with: project.http_url_to_repo(@user))
expect(page).to have_field('project_clone', with: project.http_url_to_repo)
end
 
step 'I should see an ssh link to the repository' do
Loading
Loading
Loading
Loading
@@ -18,12 +18,6 @@ module Gitlab
false
end
 
def self.http_credentials_for_user(user)
return {} unless user.respond_to?(:username)
{ user: user.username }
end
def initialize(url, credentials: nil)
@url = Addressable::URI.parse(url.strip)
@credentials = credentials
Loading
Loading
Loading
Loading
@@ -32,7 +32,7 @@ feature 'Admin disables Git access protocol', feature: true do
scenario 'shows only HTTP url' do
visit_project
 
expect(page).to have_content("git clone #{project.http_url_to_repo(admin)}")
expect(page).to have_content("git clone #{project.http_url_to_repo}")
expect(page).not_to have_selector('#clone-dropdown')
end
end
Loading
Loading
Loading
Loading
@@ -56,14 +56,8 @@ feature 'Developer views empty project instructions', feature: true do
end
 
def expect_instructions_for(protocol)
url =
case protocol
when 'ssh'
project.ssh_url_to_repo
when 'http'
project.http_url_to_repo(developer)
end
expect(page).to have_content("git clone #{url}")
msg = :"#{protocol.downcase}_url_to_repo"
expect(page).to have_content("git clone #{project.send(msg)}")
end
end
Loading
Loading
@@ -21,6 +21,6 @@ describe 'Projects > Wiki > User views Git access wiki page', :feature do
 
click_link 'Clone repository'
expect(page).to have_text("Clone repository #{project.wiki.path_with_namespace}")
expect(page).to have_text(project.wiki.http_url_to_repo(user))
expect(page).to have_text(project.wiki.http_url_to_repo)
end
end
Loading
Loading
@@ -62,11 +62,6 @@ describe Gitlab::UrlSanitizer, lib: true do
end
end
 
describe '.http_credentials_for_user' do
it { expect(described_class.http_credentials_for_user(user)).to eq({ user: 'john.doe' }) }
it { expect(described_class.http_credentials_for_user('foo')).to eq({}) }
end
describe '#sanitized_url' do
it { expect(url_sanitizer.sanitized_url).to eq("https://github.com/me/project.git") }
end
Loading
Loading
@@ -76,7 +71,7 @@ describe Gitlab::UrlSanitizer, lib: true do
 
context 'when user is given to #initialize' do
let(:url_sanitizer) do
described_class.new("https://github.com/me/project.git", credentials: described_class.http_credentials_for_user(user))
described_class.new("https://github.com/me/project.git", credentials: { user: user.username })
end
 
it { expect(url_sanitizer.credentials).to eq({ user: 'john.doe' }) }
Loading
Loading
@@ -94,7 +89,7 @@ describe Gitlab::UrlSanitizer, lib: true do
 
context 'when user is given to #initialize' do
let(:url_sanitizer) do
described_class.new("https://github.com/me/project.git", credentials: described_class.http_credentials_for_user(user))
described_class.new("https://github.com/me/project.git", credentials: { user: user.username })
end
 
it { expect(url_sanitizer.full_url).to eq("https://john.doe@github.com/me/project.git") }
Loading
Loading
Loading
Loading
@@ -1909,19 +1909,9 @@ describe Project, models: true do
describe '#http_url_to_repo' do
let(:project) { create :empty_project }
 
context 'when no user is given' do
it 'returns the url to the repo without a username' do
expect(project.http_url_to_repo).to eq("#{project.web_url}.git")
expect(project.http_url_to_repo).not_to include('@')
end
end
context 'when user is given' do
it 'returns the url to the repo with the username' do
user = build_stubbed(:user)
expect(project.http_url_to_repo(user)).to start_with("http://#{user.username}@")
end
it 'returns the url to the repo without a username' do
expect(project.http_url_to_repo).to eq("#{project.web_url}.git")
expect(project.http_url_to_repo).not_to include('@')
end
end
 
Loading
Loading
Loading
Loading
@@ -37,21 +37,11 @@ describe ProjectWiki, models: true do
describe "#http_url_to_repo" do
let(:project) { create :empty_project }
 
context 'when no user is given' do
it 'returns the url to the repo without a username' do
expected_url = "#{Gitlab.config.gitlab.url}/#{subject.path_with_namespace}.git"
it 'returns the full http url to the repo' do
expected_url = "#{Gitlab.config.gitlab.url}/#{subject.path_with_namespace}.git"
 
expect(project_wiki.http_url_to_repo).to eq(expected_url)
expect(project_wiki.http_url_to_repo).not_to include('@')
end
end
context 'when user is given' do
it 'returns the url to the repo with the username' do
user = build_stubbed(:user)
expect(project_wiki.http_url_to_repo(user)).to start_with("http://#{user.username}@")
end
expect(project_wiki.http_url_to_repo).to eq(expected_url)
expect(project_wiki.http_url_to_repo).not_to include('@')
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment