Exemplo n.º 1
0
        /// <summary>
        /// Blames the by line by command line.
        /// </summary>
        /// <param name="list">The list param.</param>
        /// <param name="line">The line param.</param>
        /// <returns>
        /// Returns blame line.
        /// </returns>
        private BlameLine BlameByLineByCommandLine(GitBlame list, int line)
        {
            if (line >= list.Lines.Count)
            {
                return null;
            }

            var lineBlame = list.Lines[line - 1];

            foreach (var item in list.Headers)
            {
                if (item.CommitGuid.Equals(lineBlame.CommitGuid))
                {
                    var blame = new BlameLine();
                    blame.Author = item.Author;
                    blame.Email = item.AuthorMail.TrimEnd('>').TrimStart('<').Trim();
                    blame.Date = item.CommitterTime;
                    blame.Line = line;
                    blame.Guid = item.CommitGuid;
                    blame.Summary = item.Summary;
                    return blame;
                }
            }

            return null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Blames the by line.
        /// </summary>
        /// <param name="blameInfo">The blame information.</param>
        /// <param name="line">The line param.</param>
        /// <returns>Returns null if not found.</returns>
        private BlameLine BlameByLine(BlameHunkCollection blameInfo, int line)
        {
            var enumerator = blameInfo.GetEnumerator();
            enumerator.MoveNext();
            var prev = enumerator.Current;
            while (enumerator.MoveNext())
            {
                var curr = enumerator.Current;

                Debug.WriteLine(prev.FinalSignature.Name + "    " + prev.FinalSignature.When + " === " + prev.FinalStartLineNumber + " === " + curr.FinalStartLineNumber + "     " + line.ToString());

                if (line >= prev.FinalStartLineNumber && line < curr.FinalStartLineNumber)
                {
                    var blame = new BlameLine();
                    blame.Line = line;
                    blame.Author = prev.FinalSignature.Name;
                    blame.Date = prev.FinalSignature.When.LocalDateTime;
                    blame.Email = prev.FinalSignature.Email;
                    return blame;
                }

                prev = enumerator.Current;
            }

            return null;
        }