diff options
author | Jan Christophersen <jan@ruken.pw> | 2017-02-17 18:18:06 +0100 |
---|---|---|
committer | Jan Christophersen <jan@ruken.pw> | 2017-02-24 16:35:34 +0100 |
commit | 150c3637521653a9e1200483376e4661ea2a46b3 (patch) | |
tree | 11c082e095baf32f2bb888f365df90fe99834544 /app/models | |
parent | 3589cc064c3ba0b5a6b062c317368dfe9183d1ba (diff) | |
download | gitlab-ce-150c3637521653a9e1200483376e4661ea2a46b3.tar.gz |
Add the username of the current user to the HTTP(S) clone URL
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 10 |
1 files changed, 8 insertions, 2 deletions
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 |