Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set http as the project default url in gitlab

Tags:

git

gitlab

when opening a project in gitlab, you will see SSH and HTTP(or HTTPS) url on the top of project home page, the SSH url is as default, but I want to set HTTP(or HTTPS) as default, so how should I do? Thanks

like image 503
yegomo Avatar asked Jan 18 '14 11:01

yegomo


People also ask

How do I change the URL of a GitLab project?

How can I change the URL on gitlab.com? Hey @simonmeusel, you can change the URL of a project by navigating to Settings -> General -> Advanced within the project and changing it in the Rename repository section. Just keep in mind you'll need to update that repository locally with the new location once you've done so.

What is the URL for GitLab pages?

Your project's URL is https://gitlab.com/websites/websites.gitlab.io . Once you enable GitLab Pages for your project, your website is published under https://websites.gitlab.io . General example: On GitLab.com, a project site is always available under https://namespace.gitlab.io/project-name.

Where are GitLab project settings?

Use the project general settings to edit your project details. Sign in to GitLab with at least the Maintainer role. On the top bar, select Menu > Projects and find your project. On the left sidebar, select Settings > General.

What is the URL for GitLab API?

If you're a GitLab.com user, the base URL is https://gitlab.com .


2 Answers

infact, you have to modify 2 other lines above the default_clone_protocol.

def default_url_to_repo(project = nil)
  project = project || @project
  current_user ? project.http_url_to_repo : project.url_to_repo
end

def default_clone_protocol
  current_user ? "http" : "ssh"
end
like image 138
Mosi Wang Avatar answered Sep 28 '22 04:09

Mosi Wang


The app/views/shared/_clone_panel.html.haml file does show:

.git-clone-holder.input-group
  .input-group-btn
    %button{class: "btn #{ 'active' if default_clone_protocol == 'ssh' }", :"data-clone" => project.ssh_url_to_repo} SSH
    %button{class: "btn #{ 'active' if default_clone_protocol == 'http' }", :"data-clone" => project.http_url_to_repo}= gitlab_config.protocol.upcase

And that default_clone_protocol is defined in app/helpers/projects_helper.rb

def default_clone_protocol
    current_user ? "ssh" : "http"
end

So you could change that code, or add a setting in config/gitlab.yml.example in order to make it a parameter.

As mentioned by Mosi Wang's answer, the function default_url_to_repo also plays a role in the definition of that order, since it returns project.url_to_repo : project.http_url_to_repo.
Reversing the order can help too.

like image 37
VonC Avatar answered Sep 28 '22 04:09

VonC