本文整理汇总了C#中GitCommands.GitModule.GetSubmodule方法的典型用法代码示例。如果您正苦于以下问题:C# GitModule.GetSubmodule方法的具体用法?C# GitModule.GetSubmodule怎么用?C# GitModule.GetSubmodule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitCommands.GitModule
的用法示例。
在下文中一共展示了GitModule.GetSubmodule方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSubmoduleText
public static string GetSubmoduleText(GitModule superproject, string name, string hash)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Submodule " + name);
sb.AppendLine();
GitModule module = superproject.GetSubmodule(name);
if (module.IsValidGitWorkingDir())
{
string error = "";
CommitData data = CommitData.GetCommitData(module, hash, ref error);
if (data == null)
{
sb.AppendLine("Commit hash:\t" + hash);
return sb.ToString();
}
string header = data.GetHeaderPlain();
string body = "\n" + data.Body.Trim();
sb.AppendLine(header);
sb.Append(body);
}
else
sb.AppendLine("Commit hash:\t" + hash);
return sb.ToString();
}
示例2: GetSubmodule
public GitModule GetSubmodule(GitModule module)
{
return module.GetSubmodule(Name);
}
示例3: ProcessSubmodulePatch
public static string ProcessSubmodulePatch(GitModule module, string text)
{
var status = GetSubmoduleStatus(text);
GitModule gitmodule = module.GetSubmodule(status.Name);
StringBuilder sb = new StringBuilder();
sb.AppendLine("Submodule " + status.Name + " Change");
sb.AppendLine();
sb.AppendLine("From:\t" + status.OldCommit);
if (gitmodule.ValidWorkingDir())
{
string error = "";
CommitData commitData = CommitData.GetCommitData(gitmodule, status.OldCommit, 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);
}
}
else
sb.AppendLine();
sb.AppendLine();
string dirty = !status.IsDirty ? "" : " (dirty)";
sb.AppendLine("To:\t\t" + status.Commit + dirty);
if (gitmodule.ValidWorkingDir())
{
string error = "";
CommitData commitData = CommitData.GetCommitData(gitmodule, status.Commit, 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);
}
}
else
sb.AppendLine();
if (status.Commit != null && status.OldCommit != null)
{
if (status.IsDirty)
{
string statusText = gitmodule.GetStatusText(false);
if (!String.IsNullOrEmpty(statusText))
{
sb.AppendLine("\nStatus:");
sb.Append(statusText);
}
}
string diffs = gitmodule.GetDiffFilesText(status.OldCommit, status.Commit);
if (!String.IsNullOrEmpty(diffs))
{
sb.AppendLine("\nDifferences:");
sb.Append(diffs);
}
}
return sb.ToString();
}
示例4: ProcessSubmoduleStatus
public static string ProcessSubmoduleStatus(GitModule module, GitSubmoduleStatus status)
{
GitModule gitmodule = module.GetSubmodule(status.Name);
StringBuilder sb = new StringBuilder();
sb.AppendLine("Submodule " + status.Name + " Change");
sb.AppendLine();
sb.AppendLine("From:\t" + (status.OldCommit ?? "null"));
CommitData oldCommitData = null;
if (gitmodule.IsValidGitWorkingDir())
{
string error = "";
if (status.OldCommit != null)
oldCommitData = CommitData.GetCommitData(gitmodule, status.OldCommit, ref error);
if (oldCommitData != null)
{
sb.AppendLine("\t\t\t\t\t" + GetRelativeDateString(DateTime.UtcNow, oldCommitData.CommitDate.UtcDateTime) + oldCommitData.CommitDate.LocalDateTime.ToString(" (ddd MMM dd HH':'mm':'ss yyyy)"));
var delim = new char[] { '\n', '\r' };
var lines = oldCommitData.Body.Trim(delim).Split(new string[] { "\r\n" }, 0);
foreach (var curline in lines)
sb.AppendLine("\t\t" + curline);
}
}
else
sb.AppendLine();
sb.AppendLine();
string dirty = !status.IsDirty ? "" : " (dirty)";
sb.AppendLine("To:\t\t" + (status.Commit ?? "null") + dirty);
CommitData commitData = null;
if (gitmodule.IsValidGitWorkingDir())
{
string error = "";
if (status.Commit != null)
commitData = CommitData.GetCommitData(gitmodule, status.Commit, ref error);
if (commitData != null)
{
sb.AppendLine("\t\t\t\t\t" + 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);
}
}
else
sb.AppendLine();
sb.AppendLine();
var submoduleStatus = gitmodule.CheckSubmoduleStatus(status.Commit, status.OldCommit, commitData, oldCommitData);
sb.Append("Type: ");
switch (submoduleStatus)
{
case SubmoduleStatus.NewSubmodule:
sb.AppendLine("New submodule");
break;
case SubmoduleStatus.FastForward:
sb.AppendLine("Fast Forward");
break;
case SubmoduleStatus.Rewind:
sb.AppendLine("Rewind");
break;
case SubmoduleStatus.NewerTime:
sb.AppendLine("Newer commit time");
break;
case SubmoduleStatus.OlderTime:
sb.AppendLine("Older commit time");
break;
case SubmoduleStatus.SameTime:
sb.AppendLine("Same commit time");
break;
default:
sb.AppendLine("Unknown");
break;
}
if (status.Commit != null && status.OldCommit != null)
{
if (status.IsDirty)
{
string statusText = gitmodule.GetStatusText(false);
if (!String.IsNullOrEmpty(statusText))
{
sb.AppendLine("\nStatus:");
sb.Append(statusText);
}
}
string diffs = gitmodule.GetDiffFilesText(status.OldCommit, status.Commit);
if (!String.IsNullOrEmpty(diffs))
{
sb.AppendLine("\nDifferences:");
sb.Append(diffs);
}
}
return sb.ToString();
}
示例5: GetSubmoduleStatus
public static GitSubmoduleStatus GetSubmoduleStatus(string text, GitModule module, string fileName)
{
if (string.IsNullOrEmpty(text))
return null;
var status = new GitSubmoduleStatus();
using (StringReader reader = new StringReader(text))
{
string line = reader.ReadLine();
if (line != null)
{
var match = Regex.Match(line, @"diff --git a/(\S+) b/(\S+)");
if (match.Groups.Count > 1)
{
status.Name = match.Groups[1].Value;
status.OldName = match.Groups[2].Value;
}
else
{
match = Regex.Match(line, @"diff --cc (\S+)");
if (match.Groups.Count > 1)
{
status.Name = match.Groups[1].Value;
status.OldName = match.Groups[1].Value;
}
}
}
while ((line = reader.ReadLine()) != null)
{
if (!line.Contains("Subproject"))
continue;
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");
hash = hash.Replace("-dirty", "");
if (c == '-')
{
status.OldCommit = hash;
}
else if (c == '+')
{
status.Commit = hash;
status.IsDirty = bdirty;
}
// TODO: Support combined merge
}
}
if (status.OldCommit != null && status.Commit != null)
{
var submodule = module.GetSubmodule(fileName);
status.AddedCommits = submodule.GetCommitCount(status.Commit, status.OldCommit);
status.RemovedCommits = submodule.GetCommitCount(status.OldCommit, status.Commit);
}
return status;
}
示例6: ProcessSubmodulePatch
public static string ProcessSubmodulePatch(GitModule module, string text)
{
StringBuilder sb = new StringBuilder();
using (StringReader reader = new StringReader(text))
{
string line = reader.ReadLine();
string moduleName = "";
if (line != null)
{
var match = Regex.Match(line, @"diff --git a/(\S+) b/(\S+)");
if (match != null && match.Groups.Count > 0)
moduleName = match.Groups[1].Value;
}
sb.AppendLine("Submodule " + moduleName + " 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);
}
GitModule gitmodule = module.GetSubmodule(moduleName);
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();
}