/
GitCommit.cs
75 lines (67 loc) · 1.79 KB
/
GitCommit.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using LibGit2Sharp;
namespace Sep.Git.Tfs.Core
{
public class GitCommit
{
private readonly Commit _commit;
public GitCommit(Commit commit)
{
_commit = commit;
}
public IEnumerable<GitTreeEntry> GetTree()
{
var treesToDescend = new Queue<Tree>(new[] {_commit.Tree});
while(treesToDescend.Any())
{
var currentTree = treesToDescend.Dequeue();
foreach(var entry in currentTree)
{
if (entry.TargetType == TreeEntryTargetType.Tree)
{
treesToDescend.Enqueue((Tree)entry.Target);
}
else if (entry.TargetType == TreeEntryTargetType.Blob)
{
yield return new GitTreeEntry(entry);
}
else
{
Trace.WriteLine("Not including " + entry.Name + ": type is " + entry.GetType().Name);
}
}
}
}
public Tuple<string,string> AuthorAndEmail
{
get
{
return new Tuple<string,string>(_commit.Author.Name, _commit.Author.Email);
}
}
public DateTimeOffset When
{
get
{
return _commit.Author.When;
}
}
public string Sha
{
get
{
return _commit.Sha;
}
}
public string Message
{
get
{
return _commit.Message;
}
}
}
}