Exemplo n.º 1
0
        public void CommitTo()
        {
            var actual   = new GitLogEntry(Entry1).CommitTo;
            var expected = "c2b90";

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void CommitFrom()
        {
            var actual   = new GitLogEntry(Entry1).CommitFrom;
            var expected = "fd792";

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void User2_quoted()
        {
            var actual   = new GitLogEntry(Entry4).User;
            var expected = new MailAddress("[email protected]", "My Name");

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 4
0
        public void ShouldEqualAnotherWhenChangesIsNull()
        {
            var gitLogEntry1 = new GitLogEntry()
            {
                AuthorName  = "AuthorName",
                AuthorEmail = "AuthorEmail",
                MergeA      = "MergeA",
                MergeB      = "MergeB",
                Changes     = null,
                CommitID    = "CommitID",
                Summary     = "Summary",
                Description = "Description",
                Time        = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero)
            };

            var gitLogEntry2 = new GitLogEntry()
            {
                AuthorName  = "AuthorName",
                AuthorEmail = "AuthorEmail",
                MergeA      = "MergeA",
                MergeB      = "MergeB",
                Changes     = null,
                CommitID    = "CommitID",
                Summary     = "Summary",
                Description = "Description",
                Time        = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero)
            };

            gitLogEntry1.AssertEqual(gitLogEntry2);
        }
        public void ShouldEqualAnotherWhenChangesIsEmpty()
        {
            var commitTime   = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero);
            var gitLogEntry1 = new GitLogEntry()
            {
                AuthorName       = "AuthorName",
                AuthorEmail      = "AuthorEmail",
                MergeA           = "MergeA",
                MergeB           = "MergeB",
                Changes          = new List <GitStatusEntry>(),
                CommitID         = "CommitID",
                Summary          = "Summary",
                Description      = "Description",
                TimeString       = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
                CommitTimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
            };

            var gitLogEntry2 = new GitLogEntry()
            {
                AuthorName       = "AuthorName",
                AuthorEmail      = "AuthorEmail",
                MergeA           = "MergeA",
                MergeB           = "MergeB",
                Changes          = new List <GitStatusEntry>(),
                CommitID         = "CommitID",
                Summary          = "Summary",
                Description      = "Description",
                TimeString       = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
                CommitTimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
            };

            gitLogEntry1.AssertEqual(gitLogEntry2);
        }
Exemplo n.º 6
0
        public void ShouldEqualAnotherWhenChangesIsNotEmpty()
        {
            var commitTime = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero);

            var gitLogEntry1 = new GitLogEntry("CommitID",
                                               "AuthorName", "AuthorEmail",
                                               "AuthorName", "AuthorEmail",
                                               "Summary", "Description",
                                               commitTime, commitTime,
                                               new List <GitStatusEntry>(new[]
            {
                new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, GitFileStatus.None, "SomeOriginalPath"),
            }),
                                               "MergeA", "MergeB");

            var gitLogEntry2 = new GitLogEntry("CommitID",
                                               "AuthorName", "AuthorEmail",
                                               "AuthorName", "AuthorEmail",
                                               "Summary",
                                               "Description",
                                               commitTime, commitTime,
                                               new List <GitStatusEntry>(new[]
            {
                new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, GitFileStatus.None, "SomeOriginalPath")
            }),
                                               "MergeA", "MergeB");

            gitLogEntry1.AssertEqual(gitLogEntry2);
        }
Exemplo n.º 7
0
        public override GitLogModel Parse(string text)
        {
            var result = new GitLogModel();

            if (!string.IsNullOrWhiteSpace(text))
            {
                var items = new List <GitLogEntry>();
                var lines = text.Split(new string[] { EndOfLineToken }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var line in lines)
                {
                    var tokens = line.Split(new string[] { ValueSplitToken }, StringSplitOptions.None).TrimAll();
                    var item   = new GitLogEntry();

                    item.Hash           = MapTokenToString(GitLogEntryLabels.Hash, tokens);
                    item.AuthorDate     = MapTokenToDateTime(GitLogEntryLabels.AuthorDate, tokens);
                    item.ChangedByEmail = MapTokenToString(GitLogEntryLabels.AuthorEmail, tokens);
                    item.ChangedByName  = MapTokenToString(GitLogEntryLabels.AuthorName, tokens);
                    item.CommitDate     = MapTokenToDateTime(GitLogEntryLabels.CommitDate, tokens);
                    item.Subject        = MapTokenToString(GitLogEntryLabels.Subject, tokens);

                    var refs = MapTokenToStringArray(GitLogEntryLabels.Refs, tokens);
                    item.Tags            = BuildTags(refs);
                    item.ReferenceBranch = GetReferenceBranch(refs);

                    items.Add(item);
                }

                result.Entries = items.OrderByDescending(x => x.CommitDate).ToArray();
            }

            return(result);
        }
        public async Task RussianLogEntriesTest()
        {
            using (var test = StartTest(TestData.TestRepoMasterCleanUnsynchronizedRussianLanguage))
            {
                var logEntries = await new GitLogTask(test.Platform, new GitObjectFactory(test.Environment), 1)
                                 .Configure(test.ProcessManager)
                                 .StartAwait();

                var commitTime = new DateTimeOffset(2017, 4, 20, 11, 47, 18, TimeSpan.FromHours(-4));

                var expected = new GitLogEntry("06d6451d351626894a30e9134f551db12c74254b",
                                               "Author Person", "*****@*****.**", "Author Person",
                                               "*****@*****.**",
                                               "Я люблю github",
                                               "",
                                               commitTime,
                                               commitTime, new List <GitStatusEntry>
                {
                    new GitStatusEntry(@"Assets\A new file.txt".ToSPath(),
                                       TestData.TestRepoMasterCleanUnsynchronizedRussianLanguage + "/Assets/A new file.txt".ToSPath(), "Assets/A new file.txt".ToSPath(),
                                       GitFileStatus.Added, GitFileStatus.None),
                });

                logEntries.Matches(new[] { expected });

                Assert.AreEqual(expected.Summary, logEntries[0].Summary);
            }
        }
        public void ShouldNotEqualAnotherWhenFieldsAreDifferent()
        {
            var commitTime   = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero);
            var gitLogEntry1 = new GitLogEntry()
            {
                AuthorName       = "AuthorName",
                AuthorEmail      = "AuthorEmail",
                MergeA           = "MergeA",
                MergeB           = "MergeB",
                Changes          = null,
                CommitID         = "CommitID",
                Summary          = "Summary",
                Description      = "Description",
                TimeString       = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
                CommitTimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
            };

            var gitLogEntry2 = new GitLogEntry()
            {
                AuthorName       = "ASDFASDF",
                AuthorEmail      = "AuthorEmail",
                MergeA           = "MergeA",
                MergeB           = "MergeB",
                Changes          = null,
                CommitID         = "CommitID",
                Summary          = "Summary",
                Description      = "Description",
                TimeString       = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
                CommitTimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
            };

            gitLogEntry1.AssertNotEqual(gitLogEntry2);
        }
Exemplo n.º 10
0
        public void Msg()
        {
            var actual   = new GitLogEntry(Entry1).Msg;
            var expected = "...";

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 11
0
        public void Time3()
        {
            var actual   = new GitLogEntry(Entry3).Time;
            var zero     = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified);
            var expected = zero.AddSeconds(1502123884); //.AddHours(-1).AddMinutes(-23);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 12
0
        public void ShouldEqualSelf()
        {
            var commitTime  = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero);
            var gitLogEntry = new GitLogEntry("CommitID",
                                              "AuthorName", "AuthorEmail",
                                              "AuthorName", "AuthorEmail",
                                              "Summary",
                                              "Description",
                                              commitTime, commitTime,
                                              new List <GitStatusEntry>(),
                                              "MergeA", "MergeB");

            gitLogEntry.AssertEqual(gitLogEntry);
        }
Exemplo n.º 13
0
 public static void AssertEqual(this GitLogEntry gitLogEntry, GitLogEntry other)
 {
     gitLogEntry.AuthorName.Should().Be(other.AuthorName);
     gitLogEntry.CommitName.Should().Be(other.CommitName);
     gitLogEntry.AuthorEmail.Should().Be(other.AuthorEmail);
     gitLogEntry.CommitEmail.Should().Be(other.CommitEmail);
     gitLogEntry.MergeA.Should().Be(other.MergeA);
     gitLogEntry.MergeB.Should().Be(other.MergeB);
     gitLogEntry.Changes.AssertEqual(other.Changes);
     gitLogEntry.CommitID.Should().Be(other.CommitID);
     gitLogEntry.Summary.Should().Be(other.Summary);
     gitLogEntry.Description.Should().Be(other.Description);
     gitLogEntry.Time.Should().Be(other.Time);
     gitLogEntry.CommitTime.Should().Be(other.CommitTime);
 }
Exemplo n.º 14
0
        public void ShouldEqualSelf()
        {
            var gitLogEntry = new GitLogEntry()
            {
                AuthorName  = "AuthorName",
                AuthorEmail = "AuthorEmail",
                MergeA      = "MergeA",
                MergeB      = "MergeB",
                Changes     = new List <GitStatusEntry>(),
                CommitID    = "CommitID",
                Summary     = "Summary",
                Description = "Description",
                Time        = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero)
            };

            gitLogEntry.AssertEqual(gitLogEntry);
        }
        public void ShouldNotEqualAnotherWhenChangesAreDifferent()
        {
            var commitTime = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero);

            var gitLogEntry1 = new GitLogEntry()
            {
                AuthorName  = "AuthorName",
                AuthorEmail = "AuthorEmail",
                MergeA      = "MergeA",
                MergeB      = "MergeB",
                Changes     = new List <GitStatusEntry>(new[]
                {
                    new GitStatusEntry("ASDFASDF", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added,
                                       "SomeOriginalPath"),
                }),
                CommitID         = "CommitID",
                Summary          = "Summary",
                Description      = "Description",
                TimeString       = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
                CommitTimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
            };

            var gitLogEntry2 = new GitLogEntry()
            {
                AuthorName  = "AuthorName",
                AuthorEmail = "AuthorEmail",
                MergeA      = "MergeA",
                MergeB      = "MergeB",
                Changes     = new List <GitStatusEntry>(new[]
                {
                    new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added,
                                       "SomeOriginalPath")
                }),
                CommitID         = "CommitID",
                Summary          = "Summary",
                Description      = "Description",
                TimeString       = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
                CommitTimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
            };

            gitLogEntry1.AssertNotEqual(gitLogEntry2);
        }
Exemplo n.º 16
0
        public void EmptyListShouldNotEqualListOf1()
        {
            var commitTime = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero);

            var entries = new[]
            {
                new GitLogEntry("CommitID",
                                "AuthorName", "AuthorEmail",
                                "AuthorName", "AuthorEmail",
                                "Summary",
                                "Description",
                                commitTime, commitTime,
                                new List <GitStatusEntry>(),
                                "MergeA", "MergeB")
            };

            GitLogEntry[] otherEntries = new GitLogEntry[0];

            entries.AssertNotEqual(otherEntries);
        }
Exemplo n.º 17
0
        public void EmptyListShouldNotEqualListOf1()
        {
            var entries = new[]
            {
                new GitLogEntry
                {
                    AuthorName  = "AuthorName",
                    AuthorEmail = "AuthorEmail",
                    MergeA      = "MergeA",
                    MergeB      = "MergeB",
                    Changes     = new List <GitStatusEntry>(),
                    CommitID    = "CommitID",
                    Summary     = "Summary",
                    Description = "Description",
                    Time        = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero)
                }
            };

            GitLogEntry[] otherEntries = new GitLogEntry[0];

            entries.AssertNotEqual(otherEntries);
        }
Exemplo n.º 18
0
        public void ShouldNotEqualAnotherWhenFieldsAreDifferent()
        {
            var commitTime = new DateTimeOffset(1921, 12, 23, 1, 3, 6, 23, TimeSpan.Zero);

            var gitLogEntry1 = new GitLogEntry("CommitID",
                                               "AuthorName", "AuthorEmail",
                                               "AuthorName", "AuthorEmail",
                                               "Summary",
                                               "Description",
                                               commitTime, commitTime,
                                               new List <GitStatusEntry>(),
                                               "MergeA", "MergeB");

            var gitLogEntry2 = new GitLogEntry("`CommitID",
                                               "`AuthorName", "`AuthorEmail",
                                               "`AuthorName", "`AuthorEmail",
                                               "`Summary",
                                               "`Description",
                                               commitTime, commitTime,
                                               new List <GitStatusEntry>(),
                                               "`MergeA", "`MergeB");

            gitLogEntry1.AssertNotEqual(gitLogEntry2);
        }
Exemplo n.º 19
0
        public static void AssertNotEqual(this GitLogEntry gitLogEntry, GitLogEntry other)
        {
            Action action = () => gitLogEntry.AssertEqual(other);

            action.ShouldThrow <AssertionException>();
        }