Good day.
I want to display all the names of commits of a specific repository in the console.
It turns out only to display the last name of the commit. I derive remotely. It makes no sense to clone them locally.
I use library LibGit2Sharp .
My method, which displays the last commit remotely:

public string GetHash(string url) { string s = Convert.ToString(url); var refer = Repository.ListRemoteReferences(s).FirstOrDefault() as SymbolicReference; return refer.Target.TargetIdentifier; } 
  • In order to get "commit names" (as I understand it, commit messages), you will at least have to dump half of the repository for yourself. Either by handles implement the "dump http protocol" and knowing the last commit in the branch, get the "commit object", parse it, pull out the message and the parent commit (s). And repeat this procedure to obtain the desired depth. - KoVadim

1 answer 1

Such code will return the first element of the sequence that the ListRemoteReferences method ListRemoteReferences :

 var refer = Repository.ListRemoteReferences(s).FirstOrDefault() as SymbolicReference; 

Try this:

 var refer = Repository.ListRemoteReferences(s); foreach(var refen in refer) { Console.WriteLine(refen.Target.TargetIdentifier); } 
  • I apologize, but I still do not really understand this. - Vladislavs Geidans
  • But there is a bug. Cannot apply indexing with the system.Collections.Generic.IEnumerable <LibGit2Sharp.Reference> ' - Vladislavs Geidans
  • @VladislavsGeidans, updated the answer, try differently. - Gardes
  • Thank you, it works. - Vladislavs Geidans
  • one
    @VladislavsGeidans if everything works, put a green check mark and upvote. - Ev_Hyper