• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GitCommands.GitBlame类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中GitCommands.GitBlame的典型用法代码示例。如果您正苦于以下问题:C# GitBlame类的具体用法?C# GitBlame怎么用?C# GitBlame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GitBlame类属于GitCommands命名空间,在下文中一共展示了GitBlame类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadBlame

        public void LoadBlame(string guid, string fileName, RevisionGrid revGrid)
        {
            var scrollpos = BlameFile.ScrollPos;

            var blameCommitter = new StringBuilder();
            var blameFile = new StringBuilder();
            _revGrid = revGrid;

            _blame = GitCommandHelpers.Blame(fileName, guid);

            for (int i = 0; i < _blame.Lines.Count; i++ )
            {
                GitBlameLine blameLine = _blame.Lines[i];
                GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(blameLine.CommitGuid);
                if (i > 0 && _blame.Lines[i-1].CommitGuid == blameLine.CommitGuid)
                {
                    blameCommitter.AppendLine(new string(' ', 200));
                } else
                {
                    blameCommitter.AppendLine((blameHeader.Author + " - " + blameHeader.AuthorTime.ToString() + " - " + blameHeader.FileName + new string(' ', 100)).Trim(new char[] { '\r', '\n' }));
                }
                if (blameLine.LineText == null )
                    blameFile.AppendLine("");
                else
                    blameFile.AppendLine(blameLine.LineText.Trim(new char[] { '\r', '\n' }));
            }

            BlameCommitter.ViewText("committer.txt", blameCommitter.ToString());
            BlameFile.ViewText(fileName, blameFile.ToString());
            BlameFile.ScrollPos = scrollpos;

            BlameFile_SelectedLineChanged(null, 0);
        }
开发者ID:chifteur,项目名称:gitextensions,代码行数:33,代码来源:BlameControl.cs


示例2: TestConstructor

 public void TestConstructor()
 {
     GitBlame blame = new GitBlame();
     Assert.IsNotNull(blame);
     Assert.IsNotNull(blame.Headers);
     Assert.IsNotNull(blame.Lines);
 }
开发者ID:fraga,项目名称:gitextensionstest,代码行数:7,代码来源:GitBlameTest.cs


示例3: TestFindHeaderForCommitGuid

        public void TestFindHeaderForCommitGuid()
        {
            GitBlame blame = new GitBlame();
            string expectedCommitGuid = Guid.NewGuid().ToString();

            GitBlameHeader expectedHeader = new GitBlameHeader { CommitGuid = expectedCommitGuid };

            blame.Headers.Add(expectedHeader);
            Assert.IsTrue(blame.FindHeaderForCommitGuid(expectedCommitGuid).Equals(expectedHeader));
        }
开发者ID:fraga,项目名称:gitextensionstest,代码行数:10,代码来源:GitBlameTest.cs


示例4: LoadBlame

        public void LoadBlame(GitRevision revision, List<string> children, string fileName, RevisionGrid revGrid, Control controlToMask, Encoding encoding)
        {
            //refresh only when something changed
            if (revision.Equals(CommitInfo.Revision) && fileName == _fileName && revGrid == _revGrid && encoding == _encoding)
                return;

            if (controlToMask != null)
                controlToMask.Mask();

            var scrollpos = BlameFile.ScrollPos;

            var blameCommitter = new StringBuilder();
            var blameFile = new StringBuilder();
            _revGrid = revGrid;
            _fileName = fileName;
            _encoding = encoding;
            string guid = revision.Guid;

            blameLoader.Load(() =>
            {
                _blame = Module.Blame(fileName, guid, encoding);
            },
            () =>
            {

                for (int i = 0; i < _blame.Lines.Count; i++)
                {
                    GitBlameLine blameLine = _blame.Lines[i];
                    GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(blameLine.CommitGuid);
                    if (i > 0 && _blame.Lines[i - 1].CommitGuid == blameLine.CommitGuid)
                    {
                        blameCommitter.AppendLine(new string(' ', 200));
                    }
                    else
                    {
                        blameCommitter.AppendLine((blameHeader.Author + " - " + blameHeader.AuthorTime + " - " + blameHeader.FileName + new string(' ', 100)).Trim(new[] { '\r', '\n' }));
                    }
                    if (blameLine.LineText == null)
                        blameFile.AppendLine("");
                    else
                        blameFile.AppendLine(blameLine.LineText.Trim(new char[] { '\r', '\n' }));
                }

                BlameCommitter.ViewText("committer.txt", blameCommitter.ToString());
                BlameFile.ViewText(fileName, blameFile.ToString());
                BlameFile.ScrollPos = scrollpos;

                CommitInfo.SetRevisionWithChildren(revision, children);

                if (controlToMask != null)
                    controlToMask.UnMask();
            });
        }
开发者ID:kunigaku,项目名称:gitextensions,代码行数:53,代码来源:BlameControl.cs


示例5: Blame

        public GitBlame Blame(string filename, string from, string lines, Encoding encoding)
        {
            from = FixPath(from);
            filename = FixPath(filename);
            string blameCommand = string.Format("blame --porcelain -M -w -l{0} \"{1}\" -- \"{2}\"", lines != null ? " -L " + lines : "", from, filename);
            var itemsStrings =
                RunCacheableCmd(
                    AppSettings.GitCommand,
                    blameCommand,
                    LosslessEncoding
                    )
                    .Split('\n');

            GitBlame blame = new GitBlame();

            GitBlameHeader blameHeader = null;
            GitBlameLine blameLine = null;

            for (int i = 0; i < itemsStrings.GetLength(0); i++)
            {
                try
                {
                    string line = itemsStrings[i];

                    //The contents of the actual line is output after the above header, prefixed by a TAB. This is to allow adding more header elements later.
                    if (line.StartsWith("\t"))
                    {
                        blameLine.LineText = line.Substring(1) //trim ONLY first tab
                                                 .Trim(new char[] { '\r' }); //trim \r, this is a workaround for a \r\n bug
                        blameLine.LineText = ReEncodeStringFromLossless(blameLine.LineText, encoding);
                    }
                    else if (line.StartsWith("author-mail"))
                        blameHeader.AuthorMail = ReEncodeStringFromLossless(line.Substring("author-mail".Length).Trim());
                    else if (line.StartsWith("author-time"))
                        blameHeader.AuthorTime = DateTimeUtils.ParseUnixTime(line.Substring("author-time".Length).Trim());
                    else if (line.StartsWith("author-tz"))
                        blameHeader.AuthorTimeZone = line.Substring("author-tz".Length).Trim();
                    else if (line.StartsWith("author"))
                    {
                        blameHeader = new GitBlameHeader();
                        blameHeader.CommitGuid = blameLine.CommitGuid;
                        blameHeader.Author = ReEncodeStringFromLossless(line.Substring("author".Length).Trim());
                        blame.Headers.Add(blameHeader);
                    }
                    else if (line.StartsWith("committer-mail"))
                        blameHeader.CommitterMail = line.Substring("committer-mail".Length).Trim();
                    else if (line.StartsWith("committer-time"))
                        blameHeader.CommitterTime = DateTimeUtils.ParseUnixTime(line.Substring("committer-time".Length).Trim());
                    else if (line.StartsWith("committer-tz"))
                        blameHeader.CommitterTimeZone = line.Substring("committer-tz".Length).Trim();
                    else if (line.StartsWith("committer"))
                        blameHeader.Committer = ReEncodeStringFromLossless(line.Substring("committer".Length).Trim());
                    else if (line.StartsWith("summary"))
                        blameHeader.Summary = ReEncodeStringFromLossless(line.Substring("summary".Length).Trim());
                    else if (line.StartsWith("filename"))
                        blameHeader.FileName = ReEncodeFileNameFromLossless(line.Substring("filename".Length).Trim());
                    else if (line.IndexOf(' ') == 40) //SHA1, create new line!
                    {
                        blameLine = new GitBlameLine();
                        var headerParams = line.Split(' ');
                        blameLine.CommitGuid = headerParams[0];
                        if (headerParams.Length >= 3)
                        {
                            blameLine.OriginLineNumber = int.Parse(headerParams[1]);
                            blameLine.FinalLineNumber = int.Parse(headerParams[2]);
                        }
                        blame.Lines.Add(blameLine);
                    }
                }
                catch
                {
                    //Catch all parser errors, and ignore them all!
                    //We should never get here...
                    AppSettings.GitLog.Log("Error parsing output from command: " + blameCommand + "\n\nPlease report a bug!");
                }
            }

            return blame;
        }
开发者ID:saland,项目名称:gitextensions,代码行数:79,代码来源:GitModule.cs


示例6: Blame

        public static GitBlame Blame(string filename, string from)
        {
            from = FixPath(from);
            filename = FixPath(filename);
            string blameCommand = string.Format("blame --porcelain -M -w -l \"{0}\" -- \"{1}\"", from, filename);
            var itemsStrings =
                RunCmd(
                    Settings.GitCommand,
                    blameCommand
                    )
                    .Split('\n');

            GitBlame blame = new GitBlame();

            GitBlameHeader blameHeader = null;
            GitBlameLine blameLine = null;

            for (int i = 0; i < itemsStrings.GetLength(0); i++)
            {
                try
                {
                    string line = itemsStrings[i];

                    //The contents of the actual line is output after the above header, prefixed by a TAB. This is to allow adding more header elements later.
                    if (line.StartsWith("\t"))
                        blameLine.LineText = line.Substring(1).Trim(new char[] { '\r' });//trim first tab
                    else
                        if (line.StartsWith("author-mail"))
                            blameHeader.AuthorMail = line.Substring("author-mail".Length).Trim();
                        else
                            if (line.StartsWith("author-time"))
                                blameHeader.AuthorTime = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(int.Parse(line.Substring("author-time".Length).Trim()));
                            else
                                if (line.StartsWith("author-tz"))
                                    blameHeader.AuthorTimeZone = line.Substring("author-tz".Length).Trim();
                                else
                                    if (line.StartsWith("author"))
                                    {
                                        blameHeader = new GitBlameHeader();
                                        blameHeader.CommitGuid = blameLine.CommitGuid;
                                        blameHeader.Author = line.Substring("author".Length).Trim();
                                        blame.Headers.Add(blameHeader);
                                    }
                                    else
                                        if (line.StartsWith("committer-mail"))
                                            blameHeader.CommitterMail = line.Substring("committer-mail".Length).Trim();
                                        else
                                            if (line.StartsWith("committer-time"))
                                                blameHeader.CommitterTime = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(int.Parse(line.Substring("committer-time".Length).Trim()));
                                            else
                                                if (line.StartsWith("committer-tz"))
                                                    blameHeader.CommitterTimeZone = line.Substring("committer-tz".Length).Trim();
                                                else
                                                    if (line.StartsWith("committer"))
                                                        blameHeader.Committer = line.Substring("committer".Length).Trim();
                                                    else
                                                        if (line.StartsWith("summary"))
                                                            blameHeader.Summary = line.Substring("summary".Length).Trim();
                                                        else
                                                            if (line.StartsWith("filename"))
                                                                blameHeader.FileName = line.Substring("filename".Length).Trim();
                                                            else
                                                                if (line.IndexOf(' ') == 40) //SHA1, create new line!
                                                                {
                                                                    blameLine = new GitBlameLine();
                                                                    blameLine.CommitGuid = line.Substring(0, 40);
                                                                    blame.Lines.Add(blameLine);
                                                                }
                }
                catch
                {
                    //Catch all parser errors, and ignore them all!
                    //We should never get here...
                    Settings.GitLog.Log("Error parsing output from command: " + blameCommand + "\n\nPlease report a bug!");
                }
            }

            return blame;
        }
开发者ID:avish,项目名称:gitextensions,代码行数:79,代码来源:GitCommandsHelper.cs


示例7: Blame

        public static List<GitBlame> Blame(string filename, string from)
        {
            from = FixPath(from);
            filename = FixPath(filename);
            string[] itemsStrings = RunCmd(Settings.GitCommand, "blame -M -w -l \"" + from + "\" -- \"" + filename + "\"").Split('\n');

            List<GitBlame> items = new List<GitBlame>();

            GitBlame item = null;
            string lastCommitGuid = "";

            Color color1 = Color.Azure;
            Color color2 = Color.Ivory;
            Color currentColor = color1;

            foreach (string itemsString in itemsStrings)
            {
                if (itemsString.Length > 50)
                {
                    string commitGuid = itemsString.Substring(0, 40).Trim();

                    if (lastCommitGuid != commitGuid)
                    {
                        if (currentColor == color1)
                            currentColor = color2;
                        else
                            currentColor = color1;
                    }

                    {
                        item = new GitBlame();
                        item.color = currentColor;
                        item.CommitGuid = commitGuid;
                        items.Add(item);
                    }

                    int codeIndex = itemsString.IndexOf(')', 41) + 1;
                    if (codeIndex > 41)
                    {
                        if (lastCommitGuid != commitGuid)
                            item.Author = itemsString.Substring(41, codeIndex - 41).Trim();

                        if (!string.IsNullOrEmpty(item.Text))
                            item.Text += Environment.NewLine;
                        item.Text += itemsString.Substring(codeIndex).Trim(new char[] { '\r' });
                    }

                    lastCommitGuid = commitGuid;
                }
            }

            return items;
        }
开发者ID:Gitulf,项目名称:gitextensions,代码行数:53,代码来源:GitCommands.cs


示例8: Blame

        public static List<GitBlame> Blame(string filename, string from)
        {
            from = FixPath(from);
            filename = FixPath(filename);
            var itemsStrings =
                RunCmd(
                    Settings.GitCommand,
                    string.Format("blame -M -w -l \"{0}\" -- \"{1}\"", from, filename))
                    .Split('\n');

            var items = new List<GitBlame>();

            GitBlame item;
            var lastCommitGuid = "";

            var color1 = Color.Azure;
            var color2 = Color.Ivory;
            var currentColor = color1;

            foreach (var itemsString in itemsStrings)
            {
                if (itemsString.Length <= 50)
                    continue;

                var commitGuid = itemsString.Substring(0, 40).Trim();

                if (lastCommitGuid != commitGuid)
                    currentColor = currentColor == color1 ? color2 : color1;

                item = new GitBlame {color = currentColor, CommitGuid = commitGuid};
                items.Add(item);

                var codeIndex = itemsString.IndexOf(')', 41) + 1;
                if (codeIndex > 41)
                {
                    if (lastCommitGuid != commitGuid)
                        item.Author = itemsString.Substring(41, codeIndex - 41).Trim();

                    if (!string.IsNullOrEmpty(item.Text))
                        item.Text += Environment.NewLine;
                    item.Text += itemsString.Substring(codeIndex).Trim(new[] {'\r'});
                }

                lastCommitGuid = commitGuid;
            }

            return items;
        }
开发者ID:TwistedHope,项目名称:gitextensions,代码行数:48,代码来源:GitCommands.cs


示例9: LoadBlame

        public void LoadBlame(string guid, string fileName, RevisionGrid revGrid = null)
        {
            var scrollpos = BlameFile.ScrollPos;

            _revGrid = revGrid;
            Blame = Settings.Module.Blame(fileName, guid);

            LoadBlame_SetupBlameCommitter();
            LoadBlame_SetupBlameFile(fileName, scrollpos);
            commitInfo.SetRevision(guid);
        }
开发者ID:dominiqueplante,项目名称:gitextensions,代码行数:11,代码来源:BlameControl.cs


示例10: LoadBlame

        public void LoadBlame(GitRevision revision, List<string> children, string fileName, RevisionGrid revGrid, Control controlToMask, Encoding encoding)
        {
            //refresh only when something changed
            if (revision.Equals(CommitInfo.Revision) && fileName == _fileName && revGrid == _revGrid && encoding == _encoding)
                return;

            if (controlToMask != null)
                controlToMask.Mask();

            var scrollpos = BlameFile.ScrollPos;

            _revGrid = revGrid;
            _fileName = fileName;
            _encoding = encoding;
            string guid = revision.Guid;

            blameLoader.Load(() => _blame = Module.Blame(fileName, guid, encoding),
                () => ProcessBlame(revision, children, controlToMask, scrollpos));
        }
开发者ID:kunimitaiyoh,项目名称:gitextensions,代码行数:19,代码来源:BlameControl.cs


示例11: LoadBlame

        public void LoadBlame(GitRevision revision, List<string> children, string fileName, RevisionGrid revGrid, Control controlToMask, Encoding encoding)
        {
            //refresh only when something changed
            string guid = revision.Guid;
            if (guid.Equals(_blameHash) && fileName == _fileName && revGrid == _revGrid && encoding == _encoding)
                return;

            if (controlToMask != null)
                controlToMask.Mask();

            var scrollpos = BlameFile.ScrollPos;

            int line = 0;
            if (_clickedBlameLine.CommitGuid == guid)
                line = _clickedBlameLine.OriginLineNumber;
            _revGrid = revGrid;
            _fileName = fileName;
            _encoding = encoding;

            blameLoader.Load(() => _blame = Module.Blame(fileName, guid, encoding),
                () => ProcessBlame(revision, children, controlToMask, line, scrollpos));
        }
开发者ID:feinstaub,项目名称:gitextensions,代码行数:22,代码来源:BlameControl.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GitCommands.GitCommands类代码示例发布时间:2022-05-26
下一篇:
C# X86.Addr32类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap