Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# How to read commit time with libgit2Sharp

I am trying to list all commits in repository, their Authors and date of commit using libgit2Sharp, but the commit object doesn't have property of date/time where the commit was created.

 using (var repo = new Repository(path))
 {
     ///get commits from all branches, not just master
     var commits = repo.Commits.QueryBy(new CommitFilter { Since = repo.Refs });

     //here I can access commit's author, but not time
     commits.Select(com => new { Author = com.Author.Name, Date = com.???
  }

I didn't find any documentation of the libgit2sharp project, on the official page it says:

Let's put it simply: we currently lack proper documentation. Any help on this subject would be greatly appreciated ;-)

How can I access commit's time?

like image 973
urza.cc Avatar asked Mar 20 '23 23:03

urza.cc


1 Answers

The date a commit was authored or committed is part of the Signature, along side the name and email address. The When member of the signature is a DateTimeOffset it was authored or committed. If you're looking for the authorship date in your example, then you want:

com.Author.When
like image 141
Edward Thomson Avatar answered Apr 07 '23 19:04

Edward Thomson