public static string GetLatestCommit(string RepositoryPath) { using (var repo = new LibGit2Sharp.Repository(RepositoryPath)) { string CommitID = "NULL"; var filter = new Filter { SortBy = GitSortOptions.Topological | GitSortOptions.Reverse }; foreach (Commit c in repo.Commits.QueryBy(filter)) { CommitID = c.Id.ToString(); } return CommitID; } }
/// <summary> /// /// </summary> /// <param name="filter"></param> /// <param name="priority"></param> internal FilterRegistration(Filter filter, int priority) { System.Diagnostics.Debug.Assert(filter != null); System.Diagnostics.Debug.Assert(priority >= FilterPriorityMin && priority <= FilterPriorityMax); Filter = filter; Priority = priority; // marshal the git_filter strucutre into native memory FilterPointer = Marshal.AllocHGlobal(Marshal.SizeOf(filter.GitFilter)); Marshal.StructureToPtr(filter.GitFilter, FilterPointer, false); // register the filter with the native libary Proxy.git_filter_register(filter.Name, FilterPointer, priority); }
/// <summary> /// Returns the list of commits of the repository matching the specified <paramref name="filter"/>. /// </summary> /// <param name="filter">The options used to control which commits will be returned.</param> /// <returns>A collection of commits, ready to be enumerated.</returns> public ICommitCollection QueryBy(Filter filter) { return new EmptyCommitCollection(filter.SortBy); }