jlee-tessik
jlee-tessik

Reputation: 1520

How do I run ls-remote in libgit2sharp without a repository?

I would like to use libgit2sharp to run the equivalent of ls-remote for a remote not currently cloned on my system, the equivalent of:

git ls-remote http://www.kernel.org/pub/scm/git/git.git

In the tests, they all seem to begin with a repository cloning the remote, but I do not want to perform the clone just yet. I just want to make sure that I can communicate with the server.

I found this issue which talks about the same thing in the underlying library, but since there was no response yet, I wasn't sure if there is a way to do this or not?

Thanks!

Upvotes: 1

Views: 478

Answers (2)

Ryan Gaudion
Ryan Gaudion

Reputation: 985

It can simply be done using the ListRemoteReferences method on Repository.

See the example below:

CredentialsHandler handler = (url, usernameFromUrl, types) =>
{
    return new UsernamePasswordCredentials() 
    { 
        Username = "username", 
        Password = "password"
    };
};

var references = Repository.ListRemoteReferences(myRepoUrl, handler);

Upvotes: 0

nulltoken
nulltoken

Reputation: 67659

How do I run ls-remote in libgit2sharp without a repository?

Current version (0.21) doesn't allow it.

Issue #985 has been created to keep track of this request. Feel free to subscribe to it to be notified of its eventual progress.

Upvotes: 2

Related Questions