Authentication seems fine. Where do you see a problem? The validation check already contains Authorization
header, and hg pull
will include it in the next request as soon as the server responds with 401 Unauthorized
.
I see these problems:
hg pull
. -> API and UI should use the same kind of validation, and UI should also of course show an error msg to the user, in case the URL has a problemI now installed in Ubuntu in VirtualBox, which seems much more stable.
I triggered an import of https://www.mercurial-scm.org/repo/hg, through the API, and I did NOT get the error message. So it seems the API validation check works with that Mercurial server.
Unfortunately, the import did not succeed, even after 8 hours. It's just staying on the "Import in progress" page. I also got a "500 Internal server error" on that page over night.
I also have other quite small repos which do not import successfully. Others are working fine though... I can also not find any kind of error message or log file for this import process...
I also wanted to test an import from a public Mercurial server, but unfortunately I run in Docker on a Mac, and that is so unstable, I just keep getting 500 Internal Server Error
. I will give up the Mac experiment now, and we will buy a Linux box, where Docker hopefully is more stable.
Hi Georges,
I cannot find such similar test that is done from the Web UI.
I just tested from the UI against a local netcat. It takes about 10 secs where nothing happens, till it loads the next page, which shows the "import in progress" message. Then it takes another 20sec or so till this request comes in:
GET /testrepo?cmd=capabilities HTTP/1.1
Accept-Encoding: identity
accept: application/mercurial-0.1
host: hg.ias.local:7777
user-agent: mercurial/proto-1.0 (Mercurial 6.1.1)
This looks completely identical to the request I get when I clone that repo from the command line, so I assume it is coming from native Mercurial, and not the UI.
When I import the exact same repo URL through the API, I get this request:
GET /testrepo/?cmd=capabilities HTTP/1.1
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
User-Agent: Ruby
Authorization: Basic bWd1Og==
Connection: close
Host: hg.ias.local:7777
Notable differences:
Accept-Encoding
, Accept
, and User-Agent
are completely differentAuthorization
is missing from the UI requestFirst one might or might not be a problem. Second one definitely is, although I couldn't get it to work. Third one is I think normal behaviour, the hg client will simply retry the request with authentication included when the server denies access.
Further investigation:
ValidateRemoteGitEndpointService.execute
actually knows about Mercurial."vcs_type": "hg"
in the curl
call. I only found this by looking at the source code, is this supposed to be documented somewhere?hg
command line. Turns out my Mercurial server (a very old Rhodecode) requires the Accept: application/mercurial-0.1
header to be set, otherwise the capabilities request is ignored.If there is interest, I can further investigate this, otherwise, if it's just because of my very old Rhodecode server, and no one else is having this problem, feel free to close.
Replying to myself: That method is indeed the culprit.
I just:
app/services/import/validate_remote_git_endpoint_service.rb
and changed the ValidateRemoteGitEndpointService.execute
method to always return ServiceResponse.success
andI try to use the Rest API to create a new project (POST /projects
) and have it automatically import from an existing Mercurial repository by specifying import_url
.
This works just fine in the UI, but fails in the API with:
{"message":"http://.... is not a valid HTTP Git repository"}
From a quick glance at the source code, in lib/api/projects.rb
there is a call to validate_git_import_url()
, which seems to check for a Git repository and doesn't know about Mercurial.
Example curl
call:
curl -s --header 'PRIVATE-TOKEN: API_TOKEN' --header 'Content-Type: application/json' --data '{"path":"my-repository","import_url":"http://user:password@hg.local/my_repository"}' http://gitlab.local/api/v4/projects