本文整理汇总了C#中GitCommands.GitItemStatus类的典型用法代码示例。如果您正苦于以下问题:C# GitItemStatus类的具体用法?C# GitItemStatus怎么用?C# GitItemStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitItemStatus类属于GitCommands命名空间,在下文中一共展示了GitItemStatus类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:feinstaub,项目名称:gitextensions,代码行数:31,代码来源:GitUIExtensions.cs
示例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);
}
开发者ID:sharwell,项目名称:gitextensions,代码行数:7,代码来源:GitUIExtensions.cs
示例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;
}
开发者ID:shivan,项目名称:gitextensions,代码行数:30,代码来源:GitUIExtensions.cs
示例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));
}
开发者ID:akrisiun,项目名称:gitextensions,代码行数:14,代码来源:CommitAutoCompleteProvider.cs
示例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);
}
}
开发者ID:tt,项目名称:gitextensions,代码行数:15,代码来源:Commit.cs
示例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);
}
}
开发者ID:spidercat,项目名称:gitextensions,代码行数:21,代码来源:Commit.cs
示例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;
}
开发者ID:kunigaku,项目名称:gitextensions,代码行数:38,代码来源:GitUIExtensions.cs
示例8: GetFullPathFromGitItemStatus
public static string GetFullPathFromGitItemStatus(GitModule gitModule, GitItemStatus gitItemStatus)
{
return GetFullPathFromFilename(gitModule, gitItemStatus.Name);
}
开发者ID:holstebroe,项目名称:gitextensions,代码行数:4,代码来源:FormBrowseUtil.cs
示例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);
}
开发者ID:sharwell,项目名称:gitextensions,代码行数:25,代码来源:GitUIExtensions.cs
示例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;
}
开发者ID:Gitulf,项目名称:gitextensions,代码行数:52,代码来源:GitCommands.cs
示例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;
}
开发者ID:Gitulf,项目名称:gitextensions,代码行数:27,代码来源:GitCommands.cs
示例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;
});
}
}
开发者ID:sharwell,项目名称:gitextensions,代码行数:21,代码来源:GitUIExtensions.cs
示例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();
}
开发者ID:pcworld,项目名称:gitextensions,代码行数:23,代码来源:FormCommit.cs
示例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;
});
}
开发者ID:ksukhonosenko,项目名称:gitextensions,代码行数:16,代码来源:GitUIExtensions.cs
示例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.");
}
}
开发者ID:vgravade,项目名称:gitextensions,代码行数:36,代码来源:FormFileHistory.cs
示例16: Unstage
private void Unstage()
{
if (Staged.GitItemStatuses.Count() > 10 && Staged.SelectedItems.Count() == Staged.GitItemStatuses.Count())
{
UnstageAllToolStripMenuItemClick(null, null);
return;
}
Cursor.Current = Cursors.WaitCursor;
EnableStageButtons(false);
try
{
var lastSelection = new List<GitItemStatus>();
if (_currentFilesList != null)
lastSelection = _currentSelection;
toolStripProgressBar1.Visible = true;
toolStripProgressBar1.Maximum = Staged.SelectedItems.Count() * 2;
toolStripProgressBar1.Value = 0;
Staged.StoreNextIndexToSelect();
var files = new List<GitItemStatus>();
var allFiles = new List<GitItemStatus>();
foreach (var item in Staged.SelectedItems)
{
toolStripProgressBar1.Value = Math.Min(toolStripProgressBar1.Maximum - 1, toolStripProgressBar1.Value + 1);
if (!item.IsNew)
{
toolStripProgressBar1.Value = Math.Min(toolStripProgressBar1.Maximum - 1, toolStripProgressBar1.Value + 1);
Module.UnstageFileToRemove(item.Name);
if (item.IsRenamed)
Module.UnstageFileToRemove(item.OldName);
}
else
{
files.Add(item);
}
allFiles.Add(item);
}
Module.UnstageFiles(files);
_skipUpdate = true;
InitializedStaged();
var stagedFiles = Staged.GitItemStatuses.ToList();
var unStagedFiles = Unstaged.GitItemStatuses.ToList();
foreach (var item in allFiles)
{
var item1 = item;
if (stagedFiles.Exists(i => i.Name == item1.Name))
continue;
var item2 = item;
if (unStagedFiles.Exists(i => i.Name == item2.Name))
continue;
if (item.IsNew && !item.IsChanged && !item.IsDeleted)
item.IsTracked = false;
else
item.IsTracked = true;
if (item.IsRenamed)
{
var clone = new GitItemStatus
{
Name = item.OldName,
IsDeleted = true,
IsTracked = true,
IsStaged = false
};
unStagedFiles.Add(clone);
item.IsRenamed = false;
item.IsNew = true;
item.IsTracked = false;
item.OldName = string.Empty;
}
item.IsStaged = false;
unStagedFiles.Add(item);
}
Staged.GitItemStatuses = stagedFiles;
Unstaged.GitItemStatuses = unStagedFiles;
_skipUpdate = false;
Staged.SelectStoredNextIndex();
toolStripProgressBar1.Value = toolStripProgressBar1.Maximum;
toolStripProgressBar1.Visible = false;
if (Staged.IsEmpty)
{
_currentFilesList = Unstaged;
RestoreSelectedFiles(Unstaged.GitItemStatuses, Staged.GitItemStatuses, lastSelection);
Unstaged.Focus();
}
}
catch (Exception ex)
//.........这里部分代码省略.........
开发者ID:Basewq,项目名称:gitextensions,代码行数:101,代码来源:FormCommit.cs
示例17: 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, item.OldName, staged);
}
else
{
SelectedDiff.ViewFile(item.Name);
}
_StageSelectedLinesToolStripMenuItem.Text = staged ? _unstageSelectedLines.Text : _stageSelectedLines.Text;
}
开发者ID:Siorghlas,项目名称:gitextensions,代码行数:23,代码来源:FormCommit.cs
示例18: GetModifiedFiles
public static List<GitItemStatus> GetModifiedFiles()
{
string status = RunCmd(Settings.GitCommand, "ls-files --modified --exclude-standard");
string[] statusStrings = status.Split('\n');
List<GitItemStatus> gitItemStatusList = new List<GitItemStatus>();
foreach (string statusString in statusStrings)
{
if (string.IsNullOrEmpty(statusString.Trim()))
continue;
GitItemStatus itemStatus = new GitItemStatus();
itemStatus.IsNew = false;
itemStatus.IsChanged = true;
itemStatus.IsDeleted = false;
itemStatus.IsTracked = true;
itemStatus.Name = statusString.Trim();
gitItemStatusList.Add(itemStatus);
}
return gitItemStatusList;
}
开发者ID:Gitulf,项目名称:gitextensions,代码行数:23,代码来源:GitCommands.cs
示例19: GetDiffFiles
public static List<GitItemStatus> GetDiffFiles(string from, string to)
{
string result = RunCachableCmd(Settings.GitCommand, "diff --name-status \"" + to + "\" \"" + from + "\"");
string[] files = result.Split('\n');
List<GitItemStatus> retVal = new List<GitItemStatus>();
foreach (string s in files)
{
if (!string.IsNullOrEmpty(s))
{
GitItemStatus gitItemStatus = new GitItemStatus();
gitItemStatus.Name = s.Substring(1).Trim();
gitItemStatus.IsNew = s[0] == 'A';
gitItemStatus.IsChanged = s[0] == 'M';
gitItemStatus.IsDeleted = s[0] == 'D';
gitItemStatus.IsTracked = true;
retVal.Add(gitItemStatus);
}
}
return retVal;
}
开发者ID:Gitulf,项目名称:gitextensions,代码行数:24,代码来源:GitCommands.cs
示例20: UnstageFilesClick
private void UnstageFilesClick(object sender, EventArgs e)
{
EnableStageButtons(false);
try
{
Cursor.Current = Cursors.WaitCursor;
if (Staged.GitItemStatuses.Count > 10 && Staged.SelectedItems.Count == Staged.GitItemStatuses.Count)
{
Loading.Visible = true;
GitCommandHelpers.ResetMixed("HEAD");
Initialize();
}
else
{
toolStripProgressBar1.Visible = true;
toolStripProgressBar1.Maximum = Staged.SelectedItems.Count * 2;
toolStripProgressBar1.Value = 0;
var files = new List<GitItemStatus>();
var allFiles = new List<GitItemStatus>();
foreach (var item in Staged.SelectedItems)
{
toolStripProgressBar1.Value = Math.Min(toolStripProgressBar1.Maximum - 1, toolStripProgressBar1.Value + 1);
if (!item.IsNew)
{
toolStripProgressBar1.Value = Math.Min(toolStripProgressBar1.Maximum - 1, toolStripProgressBar1.Value + 1);
GitCommandHelpers.UnstageFileToRemove(item.Name);
if (item.IsRenamed)
GitCommandHelpers.UnstageFileToRemove(item.OldName);
}
else
{
files.Add(item);
}
allFiles.Add(item);
}
GitCommandHelpers.UnstageFiles(files);
InitializedStaged();
var stagedFiles = (List<GitItemStatus>)Staged.GitItemStatuses;
var unStagedFiles = (List<GitItemStatus>)Unstaged.GitItemStatuses;
Unstaged.GitItemStatuses = null;
foreach (var item in allFiles)
{
var item1 = item;
if (stagedFiles.Exists(i => i.Name == item1.Name))
continue;
var item2 = item;
if (unStagedFiles.Exists(i => i.Name == item2.Name))
continue;
if (item.IsNew && !item.IsChanged && !item.IsDeleted)
item.IsTracked = false;
else
item.IsTracked = true;
if (item.IsRenamed)
{
GitItemStatus clone = new GitItemStatus();
clone.Name = item.OldName;
clone.IsDeleted = true;
clone.IsTracked = true;
clone.IsStaged = false;
unStagedFiles.Add(clone);
item.IsRenamed = false;
item.IsNew = true;
item.IsTracked = false;
item.OldName = string.Empty;
}
item.IsStaged = false;
unStagedFiles.Add(item);
}
Staged.GitItemStatuses = stagedFiles;
Unstaged.GitItemStatuses = unStagedFiles;
toolStripProgressBar1.Value = toolStripProgressBar1.Maximum;
}
toolStripProgressBar1.Visible = false;
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message);
}
EnableStageButtons(true);
Cursor.Current = Cursors.Default;
if (Settings.RevisionGraphShowWorkingDirChanges)
NeedRefresh = true;
}
开发者ID:Siorghlas,项目名称:gitextensions,代码行数:95,代码来源:FormCommit.cs
注:本文中的GitCommands.GitItemStatus类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论