本文整理汇总了C#中GitCommands.GitItemStatus类的典型用法代码示例。如果您正苦于以下问题:C# GitItemStatus类的具体用法?C# GitItemStatus怎么用?C# GitItemStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitItemStatus类属于GitCommands命名空间,在下文中一共展示了GitItemStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSelectedPatch
public static string GetSelectedPatch(this FileViewer diffViewer, string firstRevision, string secondRevision, GitItemStatus file)
{
//to simplify if-ology
if (GitRevision.IsArtificial(secondRevision) && firstRevision != GitRevision.UnstagedGuid)
{
string temp = firstRevision;
firstRevision = secondRevision;
secondRevision = temp;
}
if (IsItemUntracked(file, firstRevision, secondRevision))
{
var fullPath = Path.Combine(diffViewer.Module.WorkingDir, file.Name);
if (Directory.Exists(fullPath) && GitModule.IsValidGitWorkingDir(fullPath))
return GitCommandHelpers.GetSubmoduleText(diffViewer.Module, file.Name.TrimEnd('/'), "");
return FileReader.ReadFileContent(fullPath, diffViewer.Encoding);
}
if (file.IsSubmodule && file.SubmoduleStatus != null)
return GitCommandHelpers.ProcessSubmoduleStatus(diffViewer.Module, file.SubmoduleStatus.Result);
PatchApply.Patch patch = GetItemPatch(diffViewer.Module, file, firstRevision, secondRevision,
diffViewer.GetExtraDiffArguments(), diffViewer.Encoding);
if (patch == null)
return string.Empty;
if (file.IsSubmodule)
return GitCommandHelpers.ProcessSubmodulePatch(diffViewer.Module, patch);
return patch.Text;
}
示例2: GetSelectedPatch
public static string GetSelectedPatch(this FileViewer diffViewer, RevisionGrid grid, GitItemStatus file)
{
IList<GitRevision> revisions = grid.GetSelectedRevisions();
string firstRevision = revisions.Count > 0 ? revisions[0].Guid : null;
string secondRevision = revisions.Count == 2 ? revisions[1].Guid : null;
return GetSelectedPatch(diffViewer, firstRevision, secondRevision, file);
}
示例3: GetSelectedPatch
public static string GetSelectedPatch(this FileViewer diffViewer, RevisionGrid grid, GitItemStatus file)
{
IList<GitRevision> revisions = grid.GetSelectedRevisions();
if (revisions.Count == 0)
return null;
if (revisions[0].Guid == GitRevision.UncommittedWorkingDirGuid) //working dir changes
{
if (file.IsTracked)
return Settings.Module.GetCurrentChanges(file.Name, file.OldName, false, diffViewer.GetExtraDiffArguments(), diffViewer.Encoding);
return FileReader.ReadFileContent(Settings.WorkingDir + file.Name, diffViewer.Encoding);
}
if (revisions[0].Guid == GitRevision.IndexGuid) //index
{
return Settings.Module.GetCurrentChanges(file.Name, file.OldName, true, diffViewer.GetExtraDiffArguments(), diffViewer.Encoding);
}
var secondRevision = revisions.Count == 2 ? revisions[1].Guid : revisions[0].Guid + "^";
PatchApply.Patch patch = Settings.Module.GetSingleDiff(revisions[0].Guid, secondRevision, file.Name, file.OldName,
diffViewer.GetExtraDiffArguments(), diffViewer.Encoding);
if (patch == null)
return null;
if (file.IsSubmodule)
return GitCommandHelpers.ProcessSubmodulePatch(patch.Text);
return patch.Text;
}
示例4: GetChangedFileText
private static string GetChangedFileText(GitModule module, GitItemStatus file)
{
var changes = module.GetCurrentChanges(file.Name, file.OldName, file.IsStaged, "-U1000000", module.FilesEncoding);
if (changes != null)
return changes.Text;
var content = module.GetFileContents(file);
if (content != null)
return content;
return File.ReadAllText(Path.Combine(module.WorkingDir, file.Name));
}
示例5: ShowChanges
protected void ShowChanges(GitItemStatus item, bool staged)
{
if (item.Name.EndsWith(".png"))
{
SelectedDiff.ViewFile(item.Name);
} else
if (item.IsTracked)
{
SelectedDiff.ViewCurrentChanges(item.Name, "Patch", staged);
}
else
{
SelectedDiff.ViewFile(item.Name);
}
}
示例6: ShowChanges
protected void ShowChanges(GitItemStatus item, bool staged)
{
currentItem = item;
currentItemStaged = staged;
if (item == null)
return;
if (item.Name.EndsWith(".png"))
{
SelectedDiff.ViewFile(item.Name);
} else
if (item.IsTracked)
{
SelectedDiff.ViewCurrentChanges(item.Name, staged);
}
else
{
SelectedDiff.ViewFile(item.Name);
}
}
示例7: GetSelectedPatch
public static string GetSelectedPatch(this FileViewer diffViewer, RevisionGrid grid, GitItemStatus file)
{
IList<GitRevision> revisions = grid.GetSelectedRevisions();
if (revisions.Count == 0)
return null;
string firstRevision = revisions[0].Guid;
var secondRevision = revisions.Count == 2 ? revisions[1].Guid : null;
//to simplify if-ology
if (GitRevision.IsArtificial(secondRevision) && firstRevision != GitRevision.UnstagedGuid)
{
firstRevision = secondRevision;
secondRevision = revisions[0].Guid;
}
if (IsItemUntracked(file, firstRevision, secondRevision))
{
var fullPath = Path.Combine(grid.Module.WorkingDir, file.Name);
if (Directory.Exists(fullPath) && GitModule.ValidWorkingDir(fullPath))
return GitCommandHelpers.GetSubmoduleText(grid.Module, file.Name.TrimEnd('/'), "");
return FileReader.ReadFileContent(fullPath, diffViewer.Encoding);
}
if (file.IsSubmodule && file.SubmoduleStatus != null)
return GitCommandHelpers.ProcessSubmoduleStatus(grid.Module, file.SubmoduleStatus);
PatchApply.Patch patch = GetItemPatch(grid.Module, file, firstRevision, secondRevision,
diffViewer.GetExtraDiffArguments(), diffViewer.Encoding);
if (patch == null)
return string.Empty;
if (file.IsSubmodule)
return GitCommandHelpers.ProcessSubmodulePatch(grid.Module, patch);
return patch.Text;
}
示例8: GetFullPathFromGitItemStatus
public static string GetFullPathFromGitItemStatus(GitModule gitModule, GitItemStatus gitItemStatus)
{
return GetFullPathFromFilename(gitModule, gitItemStatus.Name);
}
示例9: GetItemPatch
private static PatchApply.Patch GetItemPatch(GitModule module, GitItemStatus file,
string firstRevision, string secondRevision, string diffArgs, Encoding encoding)
{
bool cacheResult = true;
if (GitRevision.IsArtificial(firstRevision))
{
bool staged = firstRevision == GitRevision.IndexGuid;
if (secondRevision == null || secondRevision == GitRevision.IndexGuid)
{
return module.GetCurrentChanges(file.Name, file.OldName, staged,
diffArgs, encoding);
}
cacheResult = false;
firstRevision = secondRevision;
secondRevision = string.Empty;
if (staged)
diffArgs = string.Join(" ", diffArgs, "--cached");
}
else if (secondRevision == null)
secondRevision = firstRevision + "^";
return module.GetSingleDiff(firstRevision, secondRevision, file.Name, file.OldName,
diffArgs, encoding, cacheResult);
}
示例10: GitStatus
public static List<GitItemStatus> GitStatus(bool untracked)
{
string status;
if (untracked)
status = RunCmd(Settings.GitCommand, "status --untracked=all");
else
status = RunCmd(Settings.GitCommand, "status");
string[] statusStrings = status.Split('\n');
List<GitItemStatus> gitItemStatusList = new List<GitItemStatus>();
foreach (string statusString in statusStrings)
{
if (statusString.StartsWith("#\tnew file:"))
{
GitItemStatus itemStatus = new GitItemStatus();
itemStatus.IsNew = true;
itemStatus.IsTracked = true;
itemStatus.Name = statusString.Substring(statusString.LastIndexOf(':') + 1).Trim();
gitItemStatusList.Add(itemStatus);
}
else
if (statusString.StartsWith("#\tdeleted:"))
{
GitItemStatus itemStatus = new GitItemStatus();
itemStatus.IsDeleted = true;
itemStatus.IsTracked = true;
itemStatus.Name = statusString.Substring(statusString.LastIndexOf(':') + 1).Trim();
gitItemStatusList.Add(itemStatus);
}
else
if (statusString.StartsWith("#\tmodified:"))
{
GitItemStatus itemStatus = new GitItemStatus();
itemStatus.IsChanged = true;
itemStatus.IsTracked = true;
itemStatus.Name = statusString.Substring(statusString.LastIndexOf(':') + 1).Trim();
gitItemStatusList.Add(itemStatus);
}
else
if (statusString.StartsWith("#\t"))
{
GitItemStatus itemStatus = new GitItemStatus();
itemStatus.IsNew = true;
itemStatus.Name = statusString.Substring(2).Trim();
gitItemStatusList.Add(itemStatus);
}
}
return gitItemStatusList;
}
示例11: GetAllChangedFilesFromString
public static List<GitItemStatus> GetAllChangedFilesFromString(string status)
{
string[] statusStrings = status.Split('\n');
List<GitItemStatus> gitItemStatusList = new List<GitItemStatus>();
GitItemStatus itemStatus = null;
foreach (string statusString in statusStrings)
{
if (string.IsNullOrEmpty(statusString.Trim()) || statusString.Length < 2)
continue;
if (!(itemStatus != null && itemStatus.Name == statusString.Substring(1).Trim()))
{
itemStatus = new GitItemStatus();
itemStatus.Name = statusString.Substring(1).Trim();
gitItemStatusList.Add(itemStatus);
}
itemStatus.IsNew = itemStatus.IsNew || statusString[0] == '?';
itemStatus.IsChanged = itemStatus.IsChanged || statusString[0] == 'C';
itemStatus.IsDeleted = itemStatus.IsDeleted || statusString[0] == 'R';
itemStatus.IsTracked = itemStatus.IsTracked || statusString[0] != '?';
}
return gitItemStatusList;
}
示例12: ViewChanges
public static void ViewChanges(this FileViewer diffViewer, string revision, string parentRevision, GitItemStatus file, string defaultText)
{
if (parentRevision == null)
{
if (file.TreeGuid.IsNullOrEmpty())
diffViewer.ViewGitItemRevision(file.Name, revision);
else if (!file.IsSubmodule)
diffViewer.ViewGitItem(file.Name, file.TreeGuid);
else
diffViewer.ViewText(file.Name,
LocalizationHelpers.GetSubmoduleText(diffViewer.Module, file.Name, file.TreeGuid));
}
else
{
diffViewer.ViewPatch(() =>
{
string selectedPatch = diffViewer.GetSelectedPatch(revision, parentRevision, file);
return selectedPatch ?? defaultText;
});
}
}
示例13: ShowChanges
private void ShowChanges(GitItemStatus item, bool staged)
{
_currentItem = item;
_currentItemStaged = staged;
if (item == null)
return;
long length = GetItemLength(item.Name);
if (length < 5 * 1024 * 1024) // 5Mb
SetSelectedDiff(item, staged);
else
{
SelectedDiff.Clear();
SelectedDiff.Refresh();
llShowPreview.Show();
}
_stageSelectedLinesToolStripMenuItem.Text = staged ? _unstageSelectedLines.Text : _stageSelectedLines.Text;
_stageSelectedLinesToolStripMenuItem.Image = staged ? toolUnstageItem.Image : toolStageItem.Image;
_stageSelectedLinesToolStripMenuItem.ShortcutKeyDisplayString =
GetShortcutKeys((int) (staged ? Commands.UnStageSelectedFile : Commands.StageSelectedFile)).ToShortcutKeyDisplayString();
}
示例14: ViewPatch
public static void ViewPatch(this FileViewer diffViewer, RevisionGrid grid, GitItemStatus file, string defaultText)
{
IList<GitRevision> revisions = grid.GetSelectedRevisions();
if (revisions.Count == 1 && (revisions[0].ParentGuids == null || revisions[0].ParentGuids.Length == 0))
{
diffViewer.ViewGitItem(file.Name, file.TreeGuid);
}
else
diffViewer.ViewPatch(() =>
{
string selectedPatch = diffViewer.GetSelectedPatch(grid, file);
return selectedPatch ?? defaultText;
});
}
示例15: UpdateSelectedFileViewers
private void UpdateSelectedFileViewers()
{
var selectedRows = FileChanges.GetSelectedRevisions();
if (selectedRows.Count == 0) return;
IGitItem revision = selectedRows[0];
var fileName = revision.Name;
if (string.IsNullOrEmpty(fileName))
fileName = FileName;
Text = string.Format("File History - {0}", FileName);
if (!fileName.Equals(FileName))
Text = Text + string.Format(" ({0})", fileName);
if (tabControl1.SelectedTab == BlameTab)
Blame.LoadBlame(revision.Guid, fileName, FileChanges, BlameTab, Diff.Encoding);
if (tabControl1.SelectedTab == ViewTab)
{
var scrollpos = View.ScrollPos;
View.Encoding = Diff.Encoding;
View.ViewGitItemRevision(fileName, revision.Guid);
View.ScrollPos = scrollpos;
}
if (tabControl1.SelectedTab == DiffTab)
{
GitItemStatus file = new GitItemStatus();
file.IsTracked = true;
file.Name = fileName;
Diff.ViewPatch(FileChanges, file, "You need to select at least one revision to view diff.");
}
}