forked from gitextensions/gitextensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommitInformation.cs
55 lines (47 loc) · 1.63 KB
/
CommitInformation.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
using System;
using System.Collections.Generic;
using System.Net;
namespace GitCommands
{
public class CommitInformation
{
/// <summary>
/// Private constructor
/// </summary>
private CommitInformation(string header, string body)
{
Header = header;
Body = body;
}
public string Header {get; private set;}
public string Body {get; private set;}
/// <summary>
/// Gets the commit info for module.
/// </summary>
/// <param name="module">Git module.</param>
/// <param name="sha1">The sha1.</param>
/// <returns></returns>
public static CommitInformation GetCommitInfo(GitModule module, string sha1)
{
string error = "";
CommitData data = CommitData.GetCommitData(module, sha1, ref error);
if (data == null)
return new CommitInformation(error, "");
string header = data.GetHeader();
string body = "\n\n" + WebUtility.HtmlEncode(data.Body.Trim()) + "\n\n";
return new CommitInformation(header, body);
}
/// <summary>
/// Gets the commit info from CommitData.
/// </summary>
/// <returns></returns>
public static CommitInformation GetCommitInfo(CommitData data)
{
if (data == null)
throw new ArgumentNullException("data");
string header = data.GetHeader();
string body = "\n\n" + WebUtility.HtmlEncode(data.Body.Trim()) + "\n\n";
return new CommitInformation(header, body);
}
}
}