本文整理汇总了C#中GitCommands.GitModule.ReEncodeCommitMessage方法的典型用法代码示例。如果您正苦于以下问题:C# GitModule.ReEncodeCommitMessage方法的具体用法?C# GitModule.ReEncodeCommitMessage怎么用?C# GitModule.ReEncodeCommitMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitCommands.GitModule
的用法示例。
在下文中一共展示了GitModule.ReEncodeCommitMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryParse
public static LostObject TryParse(GitModule aModule, string raw)
{
if (string.IsNullOrEmpty(raw))
throw new ArgumentException("Raw source must be non-empty string", raw);
var patternMatch = RawDataRegex.Match(raw);
// show failed assertion for unsupported cases (for developers)
// if you get this message,
// you can implement this format parsing
// or post an issue to https://github.com/gitextensions/gitextensions/issues
Debug.Assert(patternMatch.Success, "Lost object's extracted diagnostics format not implemented", raw);
// skip unsupported raw data format (for end users)
if (!patternMatch.Success)
return null;
var matchedGroups = patternMatch.Groups;
Debug.Assert(matchedGroups[4].Success);
var hash = matchedGroups[4].Value;
var result = new LostObject(GetObjectType(matchedGroups), matchedGroups[1].Value, hash);
if (result.ObjectType == LostObjectType.Commit)
{
var commitLog = GetLostCommitLog(aModule, hash);
var logPatternMatch = LogRegex.Match(commitLog);
if (logPatternMatch.Success)
{
result.Author = aModule.ReEncodeStringFromLossless(logPatternMatch.Groups[1].Value);
string encodingName = logPatternMatch.Groups[2].Value;
result.Subject = aModule.ReEncodeCommitMessage(logPatternMatch.Groups[3].Value, encodingName);
result.Date = DateTimeUtils.ParseUnixTime(logPatternMatch.Groups[4].Value);
}
}
return result;
}
示例2: UpdateBodyInCommitData
/// <summary>
/// Creates a CommitData object from formated commit info data from git. The string passed in should be
/// exact output of a log or show command using --format=LogFormat.
/// </summary>
/// <param name="data">Formated commit data from git.</param>
/// <returns>CommitData object populated with parsed info from git string.</returns>
public static void UpdateBodyInCommitData(CommitData commitData, string data, GitModule aModule)
{
if (data == null)
throw new ArgumentNullException("Data");
var lines = data.Split('\n');
var guid = lines[0];
string commitEncoding = lines[1];
int startIndex = 2;
int endIndex = lines.Length - 1;
if (lines[endIndex] == "Notes:")
endIndex--;
var message = new StringBuilder();
bool bNotesStart = false;
for (int i = startIndex; i <= endIndex; i++)
{
string line = lines[i];
if (bNotesStart)
line = " " + line;
message.AppendLine(line);
if (lines[i] == "Notes:")
bNotesStart = true;
}
//commit message is not reencoded by git when format is given
Debug.Assert(commitData.Guid == guid);
commitData.Body = aModule.ReEncodeCommitMessage(message.ToString(), commitEncoding);
}
示例3: UpdateBodyInCommitData
/// <summary>
/// Creates a CommitData object from formated commit info data from git. The string passed in should be
/// exact output of a log or show command using --format=LogFormat.
/// </summary>
/// <param name="data">Formated commit data from git.</param>
/// <returns>CommitData object populated with parsed info from git string.</returns>
public static void UpdateBodyInCommitData(CommitData commitData, string data, GitModule aModule)
{
if (data == null)
throw new ArgumentNullException("data");
var lines = data.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
var guid = lines[0];
string commitEncoding = lines[1];
const int startIndex = 2;
string message = ProccessDiffNotes(startIndex, lines);
//commit message is not reencoded by git when format is given
Debug.Assert(commitData.Guid == guid);
commitData.Body = aModule.ReEncodeCommitMessage(message, commitEncoding);
}
示例4: CreateFromFormatedData
/// <summary>
/// Creates a CommitData object from formated commit info data from git. The string passed in should be
/// exact output of a log or show command using --format=LogFormat.
/// </summary>
/// <param name="data">Formated commit data from git.</param>
/// <returns>CommitData object populated with parsed info from git string.</returns>
public static CommitData CreateFromFormatedData(string data, GitModule aModule)
{
if (data == null)
throw new ArgumentNullException("Data");
var lines = data.Split('\n');
var guid = lines[0];
// TODO: we can use this to add more relationship info like gitk does if wanted
var treeGuid = lines[1];
// TODO: we can use this to add more relationship info like gitk does if wanted
string[] parentLines = lines[2].Split(new char[]{' '});
ReadOnlyCollection<string> parentGuids = parentLines.ToList().AsReadOnly();
var author = aModule.ReEncodeStringFromLossless(lines[3]);
var authorDate = DateTimeUtils.ParseUnixTime(lines[4]);
var committer = aModule.ReEncodeStringFromLossless(lines[5]);
var commitDate = DateTimeUtils.ParseUnixTime(lines[6]);
string commitEncoding = lines[7];
int startIndex = 8;
int endIndex = lines.Length - 1;
if (lines[endIndex] == "Notes:")
endIndex--;
var message = new StringBuilder();
bool bNotesStart = false;
for (int i = startIndex; i <= endIndex; i++)
{
string line = lines[i];
if (bNotesStart)
line = " " + line;
message.AppendLine(line);
if (lines[i] == "Notes:")
bNotesStart = true;
}
//commit message is not reencoded by git when format is given
var body = aModule.ReEncodeCommitMessage(message.ToString(), commitEncoding);
var commitInformation = new CommitData(guid, treeGuid, parentGuids, author, authorDate,
committer, commitDate, body);
return commitInformation;
}
示例5: CreateFromFormatedData
/// <summary>
/// Creates a CommitData object from formated commit info data from git. The string passed in should be
/// exact output of a log or show command using --format=LogFormat.
/// </summary>
/// <param name="data">Formated commit data from git.</param>
/// <returns>CommitData object populated with parsed info from git string.</returns>
public static CommitData CreateFromFormatedData(string data, GitModule aModule)
{
if (data == null)
throw new ArgumentNullException("data");
var lines = data.Split('\n');
var guid = lines[0];
// TODO: we can use this to add more relationship info like gitk does if wanted
var treeGuid = lines[1];
// TODO: we can use this to add more relationship info like gitk does if wanted
string[] parentLines = lines[2].Split(new char[]{' '});
ReadOnlyCollection<string> parentGuids = parentLines.ToList().AsReadOnly();
var author = aModule.ReEncodeStringFromLossless(lines[3]);
var authorDate = DateTimeUtils.ParseUnixTime(lines[4]);
var committer = aModule.ReEncodeStringFromLossless(lines[5]);
var commitDate = DateTimeUtils.ParseUnixTime(lines[6]);
string commitEncoding = lines[7];
const int startIndex = 8;
string message = ProccessDiffNotes(startIndex, lines);
//commit message is not reencoded by git when format is given
var body = aModule.ReEncodeCommitMessage(message, commitEncoding);
var commitInformation = new CommitData(guid, treeGuid, parentGuids, author, authorDate,
committer, commitDate, body);
return commitInformation;
}