当前位置: 首页>>代码示例>>C#>>正文


C# GitCommands.GitItemStatus类代码示例

本文整理汇总了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;
        }
开发者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


注:本文中的GitCommands.GitItemStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。