Пример #1
0
        internal ChangeSetDetail PopulateDetails(string id, ChangeSetDetail detail)
        {
            var summaryCommand = new DiffCommand
            {
                SummaryOnly = true
            };

            if (!String.IsNullOrEmpty(id))
            {
                summaryCommand.ChangeIntroducedByRevision = id;
            }

            IStringReader summaryReader = Repository.Diff(summaryCommand).AsReader();

            ParseSummary(summaryReader, detail);

            var diffCommand = new DiffCommand
            {
                UseGitDiffFormat = true,
            };

            if (!String.IsNullOrEmpty(id))
            {
                diffCommand.ChangeIntroducedByRevision = id;
            }

            var diffReader = Repository.Diff(diffCommand).AsReader();

            GitExeRepository.ParseDiffAndPopulate(diffReader, detail);

            return(detail);
        }
Пример #2
0
        public ChangeSetDetail GetDetails(string id)
        {
            var changeSet = GetChangeSet(id);

            var detail = new ChangeSetDetail(changeSet);

            return(PopulateDetails(id, detail));
        }
Пример #3
0
 public ChangeSetDetailViewModel(ChangeSetDetail detail)
 {
     if (detail.ChangeSet != null) {
         ChangeSet = new ChangeSetViewModel(detail.ChangeSet);
     }
     Deletions = detail.Deletions;
     FilesChanged = detail.FilesChanged;
     Insertions = detail.Insertions;
     Files = detail.Files;
 }
Пример #4
0
 internal static void ParseSummaryFooter(string line, ChangeSetDetail detail)
 {
     // n files changed, n insertions(+), n deletions(-)
     var subReader = line.AsReader();
     subReader.SkipWhitespace();
     detail.FilesChanged = subReader.ReadInt();
     subReader.ReadUntil(',');
     subReader.Skip(1);
     subReader.SkipWhitespace();
     detail.Insertions = subReader.ReadInt();
     subReader.ReadUntil(',');
     subReader.Skip(1);
     subReader.SkipWhitespace();
     detail.Deletions = subReader.ReadInt();
 }
Пример #5
0
        public void ParseSummaryReadsSummaryLineFromDiff()
        {
            // Arrange
            string input = @"Bar.txt   |  1 -
             Baz.txt   |  1 +
             Hello.txt |  2 +-
             3 files changed, 2 insertions(+), 2 deletions(-)";
            var changeSetDetail = new ChangeSetDetail();

            // Act
            HgRepository.ParseSummary(input.AsReader(), changeSetDetail);

            // Assert
            Assert.Equal(3, changeSetDetail.FilesChanged);
            Assert.Equal(2, changeSetDetail.Insertions);
            Assert.Equal(2, changeSetDetail.Deletions);
        }
Пример #6
0
        internal static void ParseSummary(IStringReader reader, ChangeSetDetail detail)
        {
            while (!reader.Done)
            {
                string line = reader.ReadLine();
                if (line.Contains('|'))
                {
                    string[] parts = line.Split('|');
                    string   path  = parts[0].Trim();

                    // TODO: Figure out a way to get this information
                    detail.Files[path] = new FileInfo();
                }
                else
                {
                    // n files changed, n insertions(+), n deletions(-)
                    ParserHelpers.ParseSummaryFooter(line, detail);
                }
            }
        }
        public void Parse()
        {
            string summaryText = @"
            1	1	NGitHub.nuspec
            1	1	src/NGitHub/IRepositoryService.cs
            5	5	src/NGitHub/RepositoryService.cs
            1	1	src/NGitHub/SharedAssemblyInfo.cs
            -	-	Test.dll
             4 files changed, 8 insertions(+), 8 deletions(-)
            ";

            var detail = new ChangeSetDetail();
            GitExeRepository.ParseSummary(summaryText.AsReader(), detail);

            Assert.Equal(5, detail.Files.Count);
            Assert.Equal(4, detail.FilesChanged);
            Assert.Equal(8, detail.Insertions);
            Assert.Equal(8, detail.Deletions);
            AssertFile(detail, "NGitHub.nuspec", insertions: 1, deletions: 1, binary: false);
            AssertFile(detail, "src/NGitHub/IRepositoryService.cs", insertions: 1, deletions: 1, binary: false);
            AssertFile(detail, "src/NGitHub/RepositoryService.cs", insertions: 5, deletions: 5, binary: false);
            AssertFile(detail, "src/NGitHub/SharedAssemblyInfo.cs", insertions: 1, deletions: 1, binary: false);
            AssertFile(detail, "Test.dll", binary: true);
        }
Пример #8
0
        internal ChangeSetDetail PopulateDetails(string id, ChangeSetDetail detail)
        {
            var summaryCommand = new DiffCommand
            {
                SummaryOnly = true
            };

            if (!String.IsNullOrEmpty(id))
            {
                summaryCommand.ChangeIntroducedByRevision = id;
            }

            IStringReader summaryReader = Repository.Diff(summaryCommand).AsReader();

            ParseSummary(summaryReader, detail);

            var diffCommand = new DiffCommand
            {
                UseGitDiffFormat = true,
            };

            if (!String.IsNullOrEmpty(id))
            {
                diffCommand.ChangeIntroducedByRevision = id;
            }

            var diffReader = Repository.Diff(diffCommand).AsReader();

            GitExeRepository.ParseDiffAndPopulate(diffReader, detail);

            return detail;
        }
Пример #9
0
        internal static void ParseSummary(IStringReader reader, ChangeSetDetail detail)
        {
            while (!reader.Done)
            {
                string line = reader.ReadLine();
                if (line.Contains('|'))
                {
                    string[] parts = line.Split('|');
                    string path = parts[0].Trim();

                    // TODO: Figure out a way to get this information
                    detail.Files[path] = new FileInfo();
                }
                else
                {
                    // n files changed, n insertions(+), n deletions(-)
                    ParserHelpers.ParseSummaryFooter(line, detail);
                }
            }
        }
Пример #10
0
        public ChangeSetDetail GetDetails(string id)
        {
            var changeSet = GetChangeSet(id);

            var detail = new ChangeSetDetail(changeSet);

            return PopulateDetails(id, detail);
        }
Пример #11
0
 private void AssertFile(ChangeSetDetail detail, string path, int? insertions = null, int? deletions = null, bool binary = false)
 {
     FileInfo fi;
     Assert.True(detail.Files.TryGetValue(path, out fi));
     Assert.Equal(binary, fi.Binary);
     if (insertions != null)
     {
         Assert.Equal(insertions, fi.Insertions);
     }
     if (deletions != null)
     {
         Assert.Equal(deletions, fi.Deletions);
     }
 }
Пример #12
0
        public void PopulateStatusHandlesFilesWithSpaces()
        {
            string status = @"
            A	New File
            ";
            ChangeSetDetail detail = new ChangeSetDetail();
            detail.Files["New File"] = new FileInfo();
            GitExeRepository.PopulateStatus(status.AsReader(), detail);

            Assert.Equal(ChangeType.Added, detail.Files["New File"].Status);
        }