1

My requirement is to compare two Tags and obtain details about what has changed. To do this I'm using the below code. The code works, and I'm able to retrieve what files were added,removed and modified. However, I also need to obtain the Author who made the update to the file. How do I get the author? The 'TreeChanges' object does not have an author property.

            Tag t1 = tags.Where(t => t.FriendlyName.Equals("10.0.0.01")).First();
            Tree commitTree1 = repo.Lookup<Commit>(t1.PeeledTarget.Id.Sha).Tree;

            Tag t2 = tags.Where(t => t.FriendlyName.Equals("10.0.0.99")).Firs();
            Tree commitTree2 = repo.Lookup<Commit>(t2.PeeledTarget.Id.Sha).Tree;

            var patch = repo.Diff.Compare<TreeChanges>(commitTree1, commitTree2);

Thanks!

Tony P
  • 211
  • 5
  • 12

1 Answers1

1

The 'TreeChanges' object does not have an author property.

It does not because a "modified" file could have been, between two tag, modified by one author, then removed, then added again by another author, then modified by a third.

You would need to list all commits between those two tags, check if the file is part of that commit and get the author of that commit (commit.Author) in order to find all authors having touch said file.
See:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the reply. However, when I try to create a CommitFilter object, I get a compile time error that says CommitFilter does not contain a definition for "Since" and "Until" – Tony P Jan 05 '17 at 15:47
  • @TonyP Yes, they were removed by https://github.com/libgit2/libgit2sharp/pull/1069 and https://github.com/libgit2/libgit2sharp/commit/01b9a62c39ff99676158f9f2ab4d3a6d5632ccd7: use `IncludeReachableFrom` and `ExcludeReachableFrom` with ligbit2sharp v0.22 or more. – VonC Jan 05 '17 at 15:53
  • Thank You! Got it working with IncludeReachableFrom & ExcludeReachableFrom – Tony P Jan 05 '17 at 16:09
  • @TonyP great! Can you edit this answer with the code you ended up with? – VonC Jan 05 '17 at 16:11