Accessing Git repos hosted on Gerrit through libgit2sharp

Sett 357 ganger
Hopp til første uleste melding

Anantha Madhava

ulest,
18. mai 2017, 01:30:3018.05.2017
til Repo and Gerrit Discussion
Hello Gurus,

The query is not directly related to Gerrit but the access to Git repos hosted on Gerrit.
I am using Gerrit version V2.11.2 on Windows 2008 server R2 edition.

I have a need to access the Git repositories hosted on Gerrit through libgit2sharp V0.23.1.

Here's the code snippet I used to clone:

 

var co = new CloneOptions();

co
.CredentialsProvider= (url, fromUrl, types) => new UsernamePasswordCredentials { Username = "My_LDAP_User_Name", Password = "My_HTTP_Password_generated_from_Gerrit" };

Repository.Clone("http://GerritServerURL:8080/gerrit/playground", @"D:\GitPlay\Playground", co);



For this, I get the error - "Request failed with status code: 401"

However, when I perform Git clone through Git Bash for the same repo and same credentials, the clone succeeds.

The above code snippet also works for a Git repository hosted on Gitea server I have.

Please suggest, what config changes I need to do in Gerrit to make it work?

Cheers,
Anantha


Hugo Arès

ulest,
18. mai 2017, 06:43:3818.05.2017
til Repo and Gerrit Discussion
Try adding "/a" in the url to force authentication.

I am not sure if project is named "gerrit/playground" or just "playground" and "/gerrit" is the webapp path.

If the former, try:

Repository.Clone("http://GerritServerURL:8080/a/gerrit/playground", @"D:\GitPlay\Playground", co);

or if the latter:

Repository.Clone("http://GerritServerURL:8080/gerrit/a/playground", @"D:\GitPlay\Playground", co);

Anantha Madhava

ulest,
19. mai 2017, 00:57:1019.05.2017
til Repo and Gerrit Discussion
Hello Hugo,

In the example I quoted, 'gerrit' is just the webapp path and the repository name is 'playground'.

I tried your suggestion - Repository.Clone("http://GerritServerURL:8080/gerrit/a/playground", @"D:\GitPlay\Playground", co);

I still get "Request failed with status code: 401". Could you please suggest other alternatives?

Cheers,
Anantha

David Pursehouse

ulest,
19. mai 2017, 01:21:3919.05.2017
til Anantha Madhava, Repo and Gerrit Discussion
On Fri, May 19, 2017 at 1:57 PM Anantha Madhava <anantha...@gmail.com> wrote:
Hello Hugo,

In the example I quoted, 'gerrit' is just the webapp path and the repository name is 'playground'.

I tried your suggestion - Repository.Clone("http://GerritServerURL:8080/gerrit/a/playground", @"D:\GitPlay\Playground", co);

I still get "Request failed with status code: 401". Could you please suggest other alternatives?


Check that the request is sending authentication with the correct authentication type.  By default it should be HTTP Digest authentication.

Also, in your original mail you mentioned using the LDAP password.  Have you tried with the generated HTTP password?

 
Cheers,
Anantha

On Thursday, 18 May 2017 16:13:38 UTC+5:30, Hugo Arès wrote:
Try adding "/a" in the url to force authentication.

I am not sure if project is named "gerrit/playground" or just "playground" and "/gerrit" is the webapp path.

If the former, try:

Repository.Clone("http://GerritServerURL:8080/a/gerrit/playground", @"D:\GitPlay\Playground", co);

or if the latter:

Repository.Clone("http://GerritServerURL:8080/gerrit/a/playground", @"D:\GitPlay\Playground", co);


On Thursday, May 18, 2017 at 1:30:30 AM UTC-4, Anantha Madhava wrote:
Hello Gurus,

The query is not directly related to Gerrit but the access to Git repos hosted on Gerrit.
I am using Gerrit version V2.11.2 on Windows 2008 server R2 edition.

I have a need to access the Git repositories hosted on Gerrit through libgit2sharp V0.23.1.

Here's the code snippet I used to clone:

 

var co = new CloneOptions();

co
.CredentialsProvider= (url, fromUrl, types) => new UsernamePasswordCredentials { Username = "My_LDAP_User_Name", Password = "My_HTTP_Password_generated_from_Gerrit" };

Repository.Clone("http://GerritServerURL:8080/gerrit/playground", @"D:\GitPlay\Playground", co);



For this, I get the error - "Request failed with status code: 401"

However, when I perform Git clone through Git Bash for the same repo and same credentials, the clone succeeds.

The above code snippet also works for a Git repository hosted on Gitea server I have.

Please suggest, what config changes I need to do in Gerrit to make it work?

Cheers,
Anantha


--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anantha Madhava

ulest,
19. mai 2017, 08:37:0119.05.2017
til Repo and Gerrit Discussion, anantha...@gmail.com
Hello David,

'HTTP Digest' authentication was a real good hint.

When I looked for libgit2sharp Issues list. I found this - https://github.com/libgit2/libgit2/issues/3067.
That's the reason I was getting 'Request failed with status code: 401'.

I will have to look for alternative libraries now.

Anyway, thanks a lot for the hint.

Cheers,
Anantha
Svar alle
Svar til forfatter
Videresend
0 nye meldinger