本文整理汇总了C#中GitCommands.GitModule.GetDiffFilesText方法的典型用法代码示例。如果您正苦于以下问题:C# GitModule.GetDiffFilesText方法的具体用法?C# GitModule.GetDiffFilesText怎么用?C# GitModule.GetDiffFilesText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitCommands.GitModule
的用法示例。
在下文中一共展示了GitModule.GetDiffFilesText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessSubmodulePatch
public static string ProcessSubmodulePatch(string text)
{
StringBuilder sb = new StringBuilder();
using (StringReader reader = new StringReader(text))
{
string line;
string module = "";
while ((line = reader.ReadLine()) != null)
{
if (line.StartsWith("+++ "))
{
module = line.Substring("+++ ".Length);
var list = module.Split(new char[] { ' ' }, 2);
module = list.Length > 0 ? list[0] : "";
if (module.Length > 2 && module[1] == '/')
{
module = module.Substring(2);
break;
}
}
}
sb.AppendLine("Submodule " + module + " Change");
string fromHash = null;
string toHash = null;
bool dirtyFlag = false;
while ((line = reader.ReadLine()) != null)
{
if (line.Contains("Subproject"))
{
sb.AppendLine();
char c = line[0];
const string commit = "commit ";
string hash = "";
int pos = line.IndexOf(commit);
if (pos >= 0)
hash = line.Substring(pos + commit.Length);
bool bdirty = hash.EndsWith("-dirty");
dirtyFlag |= bdirty;
hash = hash.Replace("-dirty", "");
string dirty = !bdirty ? "" : " (dirty)";
if (c == '-')
{
fromHash = hash;
sb.AppendLine("From:\t" + hash + dirty);
}
else if (c == '+')
{
toHash = hash;
sb.AppendLine("To:\t\t" + hash + dirty);
}
string path = Settings.Module.GetSubmoduleFullPath(module);
GitModule gitmodule = new GitModule(path);
if (gitmodule.ValidWorkingDir())
{
string error = "";
CommitData commitData = CommitData.GetCommitData(gitmodule, hash, ref error);
if (commitData != null)
{
sb.AppendLine("\t\t\t\t\t" + GitCommandHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.CommitDate.UtcDateTime) + commitData.CommitDate.LocalDateTime.ToString(" (ddd MMM dd HH':'mm':'ss yyyy)"));
var delim = new char[] { '\n', '\r' };
var lines = commitData.Body.Trim(delim).Split(new string[] { "\r\n" }, 0);
foreach (var curline in lines)
sb.AppendLine("\t\t" + curline);
}
if (fromHash != null && toHash != null)
{
if (dirtyFlag)
{
string status = gitmodule.GetStatusText(false);
if (!String.IsNullOrEmpty(status))
{
sb.AppendLine("\nStatus:");
sb.Append(status);
}
}
string diffs = gitmodule.GetDiffFilesText(fromHash, toHash);
if (!String.IsNullOrEmpty(diffs))
{
sb.AppendLine("\nDifferences:");
sb.Append(diffs);
}
}
}
else
sb.AppendLine();
}
}
}
return sb.ToString();
}