本文整理汇总了C#中GitCommands.GitItem类的典型用法代码示例。如果您正苦于以下问题:C# GitItem类的具体用法?C# GitItem怎么用?C# GitItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitItem类属于GitCommands命名空间,在下文中一共展示了GitItem类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGitItemFromString
internal static GitItem CreateGitItemFromString(GitModule aModule, string itemsString)
{
if ((itemsString == null) || (itemsString.Length <= MinimumStringLength))
return null;
var guidStart = itemsString.IndexOf(' ', 7);
var item = new GitItem(aModule)
{
Mode = itemsString.Substring(0, 6),
ItemType = itemsString.Substring(7, guidStart - 7),
Guid = itemsString.Substring(guidStart + 1, 40),
Name = itemsString.Substring(guidStart + 42).Trim()
};
item.FileName = item.Name;
return item;
}
示例2: GetFileChanges
public IList<GitItem> GetFileChanges(string file)
{
file = FixPath(file);
var tree = RunGitCmd("whatchanged --all -- \"" + file + "\"");
var itemsStrings = tree.Split('\n');
var items = new List<GitItem>();
GitItem item = null;
foreach (var itemsString in itemsStrings)
{
if (itemsString.StartsWith("commit "))
{
item = new GitItem(this) { CommitGuid = itemsString.Substring(7).Trim() };
items.Add(item);
}
else if (item == null)
{
continue;
}
else if (itemsString.StartsWith("Author: "))
{
item.Author = itemsString.Substring(7).Trim();
}
else if (itemsString.StartsWith("Date: "))
{
item.Date = itemsString.Substring(7).Trim();
}
else if (!itemsString.StartsWith(":") && !string.IsNullOrEmpty(itemsString))
{
item.Name += itemsString.Trim() + Environment.NewLine;
}
else
{
if (itemsString.Length > 32)
item.Guid = itemsString.Substring(26, 7);
}
}
return items;
}
示例3: GetFullPathFromGitItem
public static string GetFullPathFromGitItem(GitModule gitModule, GitItem gitItem)
{
return GetFullPathFromFilename(gitModule, gitItem.FileName);
}
示例4: GetTree
public static List<IGitItem> GetTree(string id)
{
var tree = RunCachableCmd(Settings.GitCommand, "ls-tree -z \"" + id + "\"");
var itemsStrings = tree.Split(new char[] { '\0', '\n' });
var items = new List<IGitItem>();
foreach (var itemsString in itemsStrings)
{
if (itemsString.Length <= 53)
continue;
var item = new GitItem { Mode = itemsString.Substring(0, 6) };
var guidStart = itemsString.IndexOf(' ', 7);
item.ItemType = itemsString.Substring(7, guidStart - 7);
item.Guid = itemsString.Substring(guidStart + 1, 40);
item.Name = itemsString.Substring(guidStart + 42).Trim();
item.FileName = item.Name;
items.Add(item);
}
return items;
}
示例5: GetConflictedFiles
public static List<GitItem> GetConflictedFiles()
{
string[] unmerged = RunCmd(Settings.GitCommand, "ls-files --unmerged").Split('\n');
List<GitItem> unmergedFiles = new List<GitItem>();
string fileName = "";
foreach (string file in unmerged)
{
if (file.LastIndexOfAny(new char[] { ' ', '\t' }) > 0)
{
if (file.Substring(file.LastIndexOfAny(new char[] { ' ', '\t' }) + 1) != fileName)
{
fileName = file.Substring(file.LastIndexOfAny(new char[] { ' ', '\t' }) + 1);
GitItem gitFile = new GitItem();
gitFile.FileName = fileName;
unmergedFiles.Add(gitFile);
}
}
}
return unmergedFiles;
}
示例6: GetTree
public static List<IGitItem> GetTree(string id)
{
string tree = RunCachableCmd(Settings.GitCommand, "ls-tree \"" + id + "\"");
string[] itemsStrings = tree.Split('\n');
List<IGitItem> items = new List<IGitItem>();
foreach (string itemsString in itemsStrings)
{
GitItem item = new GitItem();
if (itemsString.Length > 53)
{
item.Mode = itemsString.Substring(0, 6);
int guidStart = itemsString.IndexOf(' ', 7);
item.ItemType = itemsString.Substring(7, guidStart - 7);
item.Guid = itemsString.Substring(guidStart + 1, 40);
item.Name = itemsString.Substring(guidStart + 42).Trim();
item.FileName = item.Name;
//if (item.ItemType == "tree")
// item.SubItems = GetTree(item.Guid);
items.Add(item);
}
}
return items;
}
示例7: GetFileName
private static string GetFileName(GitItem item)
{
var fileName = item.FileName;
if (fileName.Contains("\\") && fileName.LastIndexOf("\\") < fileName.Length)
fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1);
if (fileName.Contains("/") && fileName.LastIndexOf("/") < fileName.Length)
fileName = fileName.Substring(fileName.LastIndexOf('/') + 1);
fileName = (Path.GetTempPath() + fileName).Replace(Settings.PathSeparatorWrong, Settings.PathSeparator);
return fileName;
}
示例8: GetFileChanges
public static List<GitItem> GetFileChanges(string file)
{
file = FixPath(file);
string tree = RunCmd(Settings.GitDir + "git.cmd", "whatchanged --all -- \"" + file + "\"");
string[] itemsStrings = tree.Split('\n');
List<GitItem> items = new List<GitItem>();
GitItem item = null;
foreach (string itemsString in itemsStrings)
{
if (itemsString.StartsWith("commit "))
{
item = new GitItem();
item.CommitGuid = itemsString.Substring(7).Trim();
items.Add(item);
}
else
if (item == null)
{
continue;
}
else
if (itemsString.StartsWith("Author: "))
{
item.Author = itemsString.Substring(7).Trim();
}
else
if (itemsString.StartsWith("Date: "))
{
item.Date = itemsString.Substring(7).Trim();
}
else
if (!itemsString.StartsWith(":") && !string.IsNullOrEmpty(itemsString))
{
item.Name += itemsString.Trim() + "\n";
}
else
{
if (item != null && itemsString.Length > 32)
item.Guid = itemsString.Substring(26, 7);
}
}
return items;
}