Skip to content

Commit 5e6edd3

Browse files
committed
Commit.AuthorName, either the Github login or commit raw name <email>
1 parent 68f5c3a commit 5e6edd3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Git.hub/Commit.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,38 @@ public class PullRequestCommit
1515
{
1616
public string Sha { get; private set; }
1717
public string Url { get; private set; }
18+
19+
/// <summary>
20+
/// Github User, may be null if unbeknown to Github
21+
/// </summary>
1822
public User Author { get; private set; }
1923
public User Committer { get; private set; }
2024
public List<Ref> Parents { get; private set; }
2125
public Commit Commit { get; private set; }
26+
27+
public string AuthorName { get { return Author == null ? Commit.Author.ToString() : Author.Login; } }
2228
}
2329

2430
public class CommitAuthor
2531
{
2632
public string Name { get; private set; }
2733
public string Email { get; private set; }
2834
public DateTime Date { get; private set; }
35+
36+
public override string ToString()
37+
{
38+
if (Name != null)
39+
{
40+
if (Email != null)
41+
return string.Format("{0} <{1}>", Name, Email);
42+
else
43+
return Name;
44+
}
45+
else if (Email != null)
46+
return Email;
47+
else
48+
return "";
49+
}
2950
}
3051

3152
// Not too sure this is the same for normal commits.

0 commit comments

Comments
 (0)