本文整理汇总了C#中PatchApply.PatchFile类的典型用法代码示例。如果您正苦于以下问题:C# PatchFile类的具体用法?C# PatchFile怎么用?C# PatchFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PatchFile类属于PatchApply命名空间,在下文中一共展示了PatchFile类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRebasePatchFiles
public IList<PatchFile> GetRebasePatchFiles()
{
var patchFiles = new List<PatchFile>();
var nextFile = GetNextRebasePatch();
int next;
int.TryParse(nextFile, out next);
var files = new string[0];
if (Directory.Exists(GetRebaseDir()))
files = Directory.GetFiles(GetRebaseDir());
foreach (var fullFileName in files)
{
int n;
var file = fullFileName.Substring(fullFileName.LastIndexOf(AppSettings.PathSeparator.ToString()) + 1);
if (!int.TryParse(file, out n))
continue;
var patchFile =
new PatchFile
{
Name = file,
FullName = fullFileName,
IsNext = n == next,
IsSkipped = n < next
};
if (File.Exists(GetRebaseDir() + file))
{
string key = null;
string value = null;
foreach (var line in File.ReadLines(GetRebaseDir() + file))
{
var m = HeadersMatch.Match(line);
if (key == null)
{
if (!String.IsNullOrWhiteSpace(line) && !m.Success)
continue;
}
else if (String.IsNullOrWhiteSpace(line) || m.Success)
{
value = DecodeString(value);
switch (key)
{
case "From":
if (value.IndexOf('<') > 0 && value.IndexOf('<') < value.Length)
patchFile.Author = value.Substring(0, value.IndexOf('<')).Trim();
else
patchFile.Author = value;
break;
case "Date":
if (value.IndexOf('+') > 0 && value.IndexOf('<') < value.Length)
patchFile.Date = value.Substring(0, value.IndexOf('+')).Trim();
else
patchFile.Date = value;
break;
case "Subject":
patchFile.Subject = value;
break;
}
}
if (m.Success)
{
key = m.Groups[1].Value;
value = m.Groups[2].Value;
}
else
value = AppendQuotedString(value, line.Trim());
if (string.IsNullOrEmpty(line) ||
!string.IsNullOrEmpty(patchFile.Author) &&
!string.IsNullOrEmpty(patchFile.Date) &&
!string.IsNullOrEmpty(patchFile.Subject))
break;
}
}
patchFiles.Add(patchFile);
}
return patchFiles;
}
示例2: GetRebasePatchFiles
public static List<PatchFile> GetRebasePatchFiles()
{
var patchFiles = new List<PatchFile>();
var nextFile = GetNextRebasePatch();
int next;
int.TryParse(nextFile, out next);
var files = new string[0];
if (Directory.Exists(GetRebaseDir()))
files = Directory.GetFiles(GetRebaseDir());
foreach (var fullFileName in files)
{
int n;
var file = fullFileName.Substring(fullFileName.LastIndexOf(Settings.PathSeparator) + 1);
if (!int.TryParse(file, out n))
continue;
var patchFile =
new PatchFile
{
Name = file,
FullName = fullFileName,
IsNext = n == next,
IsSkipped = n < next
};
if (File.Exists(GetRebaseDir() + file))
{
foreach (var line in File.ReadAllLines(GetRebaseDir() + file))
{
if (line.StartsWith("From: "))
if (line.IndexOf('<') > 0 && line.IndexOf('<') < line.Length)
patchFile.Author = line.Substring(6, line.IndexOf('<') - 6).Trim();
else
patchFile.Author = line.Substring(6).Trim();
if (line.StartsWith("Date: "))
if (line.IndexOf('+') > 0 && line.IndexOf('<') < line.Length)
patchFile.Date = line.Substring(6, line.IndexOf('+') - 6).Trim();
else
patchFile.Date = line.Substring(6).Trim();
if (line.StartsWith("Subject: ")) patchFile.Subject = line.Substring(9).Trim();
if (!string.IsNullOrEmpty(patchFile.Author) &&
!string.IsNullOrEmpty(patchFile.Date) &&
!string.IsNullOrEmpty(patchFile.Subject))
break;
}
}
patchFiles.Add(patchFile);
}
return patchFiles;
}
示例3: GetInteractiveRebasePatchFiles
public IList<PatchFile> GetInteractiveRebasePatchFiles()
{
string todoFile = GetRebaseDir() + "git-rebase-todo";
string[] todoCommits = File.Exists(todoFile) ? File.ReadAllText(todoFile).Trim().Split(new char[]{'\n', '\r'}, StringSplitOptions.RemoveEmptyEntries) : null;
IList<PatchFile> patchFiles = new List<PatchFile>();
if (todoCommits != null)
{
foreach (string todoCommit in todoCommits)
{
if (todoCommit.StartsWith("#"))
continue;
string[] parts = todoCommit.Split(' ');
if (parts.Length >= 3)
{
string error = string.Empty;
CommitData data = CommitData.GetCommitData(this, parts[1], ref error);
PatchFile nextCommitPatch = new PatchFile();
nextCommitPatch.Author = string.IsNullOrEmpty(error) ? data.Author : error;
nextCommitPatch.Subject = string.IsNullOrEmpty(error) ? data.Body : error;
nextCommitPatch.Name = parts[0];
nextCommitPatch.Date = string.IsNullOrEmpty(error) ? data.CommitDate.LocalDateTime.ToString() : error;
nextCommitPatch.IsNext = patchFiles.Count == 0;
patchFiles.Add(nextCommitPatch);
}
}
}
return patchFiles;
}
示例4: GetRebasePatchFiles
public static List<PatchFile> GetRebasePatchFiles()
{
List<PatchFile> patchFiles = new List<PatchFile>();
string nextFile = GetNextRebasePatch();
int next = 0;
int.TryParse(nextFile, out next);
string[] files = new string[0];
if (Directory.Exists(GetRebaseDir()))
files = Directory.GetFiles(GetRebaseDir());
foreach (string fullFileName in files)
{
int n = 0;
string file = fullFileName.Substring(fullFileName.LastIndexOf('\\') + 1);
if (int.TryParse(file, out n))
{
PatchFile patchFile = new PatchFile();
patchFile.Name = file;
patchFile.FullName = fullFileName;
patchFile.IsNext = n == next;
patchFile.IsSkipped = n < next;
if (File.Exists(GetRebaseDir() + file))
{
foreach (string line in File.ReadAllLines(GetRebaseDir() + file))
{
if (line.StartsWith("From: "))
if (line.IndexOf('<') > 0 && line.IndexOf('<') < line.Length)
patchFile.Author = line.Substring(6, line.IndexOf('<') - 6).Trim();
else
patchFile.Author = line.Substring(6).Trim();
if (line.StartsWith("Date: "))
if (line.IndexOf('+') > 0 && line.IndexOf('<') < line.Length)
patchFile.Date = line.Substring(6, line.IndexOf('+') - 6).Trim();
else
patchFile.Date = line.Substring(6).Trim();
if (line.StartsWith("Subject: ")) patchFile.Subject = line.Substring(9).Trim();
if (!string.IsNullOrEmpty(patchFile.Author) &&
!string.IsNullOrEmpty(patchFile.Date) &&
!string.IsNullOrEmpty(patchFile.Subject))
break;
}
}
patchFiles.Add(patchFile);
}
}
return patchFiles;
}