From 150c3637521653a9e1200483376e4661ea2a46b3 Mon Sep 17 00:00:00 2001 From: Jan Christophersen Date: Fri, 17 Feb 2017 18:18:06 +0100 Subject: Add the username of the current user to the HTTP(S) clone URL --- app/models/project.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/project.rb b/app/models/project.rb index 814fd0c0f4f..6175f8dce7f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -873,8 +873,14 @@ class Project < ActiveRecord::Base url_to_repo end - def http_url_to_repo - "#{web_url}.git" + def http_url_to_repo(user = nil) + url = web_url + + if user + url.sub!(%r{\Ahttps?://}) { |protocol| "#{protocol}#{user.username}@" } + end + + "#{url}.git" end # Check if current branch name is marked as protected in the system -- cgit v1.2.1