Esempio n. 1
0
        private void gatherArguments(IEnumerable <Discussion> discussions,
                                     out HashSet <GitDiffArguments> diffArgs, out HashSet <GitShowRevisionArguments> revisionArgs)
        {
            diffArgs     = new HashSet <GitDiffArguments>();
            revisionArgs = new HashSet <GitShowRevisionArguments>();

            foreach (Discussion discussion in discussions)
            {
                Debug.Assert(discussion.Notes != null &&
                             discussion.Notes.Any() &&
                             !discussion.Notes.First().System &&
                             discussion.Notes.First().Type == "DiffNote");

                Core.Matching.DiffPosition position =
                    PositionConverter.Convert(discussion.Notes.First().Position);
                if (!Core.Context.Helpers.IsValidPosition(position))
                {
                    continue;
                }

                diffArgs.Add(new GitDiffArguments
                             (
                                 GitDiffArguments.DiffMode.Context,
                                 new GitDiffArguments.CommonArguments
                                 (
                                     position.Refs.LeftSHA,
                                     position.Refs.RightSHA,
                                     position.LeftPath,
                                     position.RightPath,
                                     null
                                 ),
                                 new GitDiffArguments.DiffContextArguments(0)
                             ));

                diffArgs.Add(new GitDiffArguments
                             (
                                 GitDiffArguments.DiffMode.Context,
                                 new GitDiffArguments.CommonArguments
                                 (
                                     position.Refs.LeftSHA,
                                     position.Refs.RightSHA,
                                     position.LeftPath,
                                     position.RightPath,
                                     null
                                 ),
                                 new GitDiffArguments.DiffContextArguments(Constants.FullContextSize)
                             ));

                if (Core.Context.Helpers.IsRightSidePosition(position))
                {
                    revisionArgs.Add(new GitShowRevisionArguments(position.RightPath, position.Refs.RightSHA));
                }
                else
                {
                    Debug.Assert(Core.Context.Helpers.IsLeftSidePosition(position));
                    revisionArgs.Add(new GitShowRevisionArguments(position.LeftPath, position.Refs.LeftSHA));
                }
            }
        }
Esempio n. 2
0
        private void gatherArguments(IEnumerable <Discussion> discussions,
                                     out HashSet <GitDiffArguments> diffArgs, out HashSet <GitShowRevisionArguments> revisionArgs)
        {
            diffArgs     = new HashSet <GitDiffArguments>();
            revisionArgs = new HashSet <GitShowRevisionArguments>();

            foreach (Discussion discussion in discussions)
            {
                Debug.Assert(discussion.Notes != null &&
                             discussion.Notes.Any() &&
                             !discussion.Notes.First().System &&
                             discussion.Notes.First().Type == "DiffNote");

                Core.Matching.DiffPosition position =
                    PositionConverter.Convert(discussion.Notes.First().Position);

                diffArgs.Add(new GitDiffArguments
                             (
                                 GitDiffArguments.DiffMode.Context,
                                 new GitDiffArguments.CommonArguments
                                 (
                                     position.Refs.LeftSHA,
                                     position.Refs.RightSHA,
                                     position.LeftPath,
                                     position.RightPath,
                                     null
                                 ),
                                 new GitDiffArguments.DiffContextArguments(0)
                             ));

                diffArgs.Add(new GitDiffArguments
                             (
                                 GitDiffArguments.DiffMode.Context,
                                 new GitDiffArguments.CommonArguments
                                 (
                                     position.Refs.LeftSHA,
                                     position.Refs.RightSHA,
                                     position.LeftPath,
                                     position.RightPath,
                                     null
                                 ),
                                 new GitDiffArguments.DiffContextArguments(Constants.FullContextSize)
                             ));

                // the same condition as in EnhancedContextMaker and SimpleContextMaker,
                // which are consumers of the cache
                if (position.RightLine != null)
                {
                    revisionArgs.Add(new GitShowRevisionArguments(position.RightPath, position.Refs.RightSHA));
                }
                else
                {
                    revisionArgs.Add(new GitShowRevisionArguments(position.LeftPath, position.Refs.LeftSHA));
                }
            }
        }
Esempio n. 3
0
        private IEnumerable <ReportedDiscussionNote> getReportedDiscussions(MergeRequestKey mrk)
        {
            DiscussionFilter discussionFilter = new DiscussionFilter(
                _currentUser, null, DiscussionFilterState.CurrentUserOnly);

            return(_getDiscussions(mrk)
                   .Where(discussion => discussionFilter.DoesMatchFilter(discussion))
                   .Where(discussion => !discussion.Notes.First().System)
                   .Select(discussion =>
            {
                DiscussionNote firstNote = discussion.Notes.First();
                Core.Matching.DiffPosition firstNotePosition = PositionConverter.Convert(firstNote.Position);
                return new ReportedDiscussionNote(firstNote.Id, discussion.Id, firstNotePosition,
                                                  firstNote.Body, firstNote.Author.Name, firstNote.Created_At);
            }));
        }