summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-03-20 10:56:43 +0100
committerRémy Coutable <remy@rymai.me>2017-03-20 16:24:01 +0100
commitbe25bbc4d2c7e3d5cf3da6f51cb7f7355295ef52 (patch)
tree4f89c264978be7e93ea7a189e8dbbdca3439babe /app
parentcd3e410110a5c6f33c5e873f8fb54883a8e11754 (diff)
downloadgitlab-ce-be25bbc4d2c7e3d5cf3da6f51cb7f7355295ef52.tar.gz
Fix ProjectWiki#http_url_to_repo signature
New Gitlab::UrlSanitizer.http_credentials_for_user method responsible for generating a credentials hash from a user. Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb8
-rw-r--r--app/models/project_wiki.rb7
2 files changed, 7 insertions, 8 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 17cf8226bcc..963faed5df9 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -880,13 +880,9 @@ class Project < ActiveRecord::Base
end
def http_url_to_repo(user = nil)
- url = web_url
+ credentials = Gitlab::UrlSanitizer.http_credentials_for_user(user)
- if user
- url.sub!(%r{\Ahttps?://}) { |protocol| "#{protocol}#{user.username}@" }
- end
-
- "#{url}.git"
+ Gitlab::UrlSanitizer.new("#{web_url}.git", credentials: credentials).full_url
end
# Check if current branch name is marked as protected in the system
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index 539b31780b3..70eef359cdd 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -42,8 +42,11 @@ class ProjectWiki
url_to_repo
end
- def http_url_to_repo
- [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('')
+ 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
end
def wiki_base_path