Exemplo n.º 1
0
        public void RebaseBlobConflictsCanResolvedAndContinued(BlobRepository sut, IObjectRepositoryContainer <BlobRepository> container, Signature signature, string message)
        {
            // Act
            CreateConflictingChange(sut, container, signature, message);
            var rebase = container.Rebase(sut.Id, "master");

            rebase.ModifiedProperties.Single(c => c.IsInConflict).Resolve(new StringBlob("y\nb\nd"));
            rebase.Continue();

            // Assert
            Assert.That(rebase.Status, Is.EqualTo(RebaseStatus.Complete));
            Assert.That(rebase.TotalStepCount, Is.EqualTo(1));
            Assert.That(container.Repositories.Single().Blob, Is.EqualTo(new StringBlob("y\nb\nd")));
        }
Exemplo n.º 2
0
        static IObjectRepositoryRebase CreateConflictingRebase(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message)
        {
            // master:    A---B
            //             \    (B & C change same property)
            // newBranch:   C   ->   A---C---B
            var a          = container.AddRepository(sut, signature, message); // A
            var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "foo");

            container.Commit(updateName.Repository, signature, message); // B
            container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1");
            var updates = a.With(c => c
                                 .Update(a.Applications[0].Pages[0], p => p.Name, "bar")
                                 .Update(a.Applications[0].Pages[0], p => p.Description, "bar")
                                 .Update(a.Applications[0].Pages[0].Fields[0], f => f.Name, "bar"));

            container.Commit(updates, signature, message);
            return(container.Rebase(sut.Id, "master"));
        }
Exemplo n.º 3
0
        public void RebaseFailsWhenUpstreamBranchContainsMigrations(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, DummyMigration migration)
        {
            // master:    A---B  (B contains a migration)
            //             \
            // newBranch:   C   ->   A---C---B

            // Arrange
            var a = container.AddRepository(sut, signature, message); // A

            // Act
            container.Commit(
                a.With(c => c.Add(a, r => r.Migrations, migration)).Repository,
                signature, message); // B
            a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1");
            container.Commit(
                a.With(a.Applications[0].Pages[0], p => p.Description, "modified description").Repository,
                signature, message); // C
            Assert.Throws <NotSupportedException>(() => container.Rebase(sut.Id, "master"));
        }
Exemplo n.º 4
0
        public void RebaseChildAddition(IServiceProvider serviceProvider, ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message)
        {
            // master:    A---B
            //             \
            // newBranch:   C   ->   A---C---B

            // Arrange
            var a = container.AddRepository(sut, signature, message); // A

            // Act
            var updateName = a.With(a.Applications[0], app => app.Name, "modified name");
            var b          = container.Commit(updateName.Repository, signature, message); // B

            a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1");
            var page    = new Page(serviceProvider, UniqueId.CreateNew(), "name", "description", new LazyChildren <Field>());
            var addPage = a.With(c => c.Add(a.Applications[0], app => app.Pages, page));

            container.Commit(addPage.Repository, signature, message); // C
            var rebase     = container.Rebase(sut.Id, "master");
            var repository = container.Repositories.Single();

            // Assert
            Assert.That(rebase.Status, Is.EqualTo(RebaseStatus.Complete));
            Assert.That(rebase.TotalStepCount, Is.EqualTo(1));
            var(commits, tip) = repository.Execute(r =>
            {
                var commitFilter = new CommitFilter
                {
                    IncludeReachableFrom = r.Head.Tip,
                    SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological,
                };
                return(r.Commits.QueryBy(commitFilter).Select(c => c.Id).ToList(), r.Head.Tip.Id);
            });
            Assert.That(commits, Has.Count.EqualTo(3));
            Assert.That(commits[0], Is.EqualTo(a.CommitId));
            Assert.That(commits[1], Is.EqualTo(b.CommitId));
            Assert.That(commits[2], Is.EqualTo(tip));
            Assert.That(repository.CommitId, Is.EqualTo(tip));
            Assert.That(repository.Applications[0].Name, Is.EqualTo("modified name"));
            Assert.That(repository.Applications[0].Pages, Has.Count.EqualTo(a.Applications[0].Pages.Count + 1));
        }
Exemplo n.º 5
0
        public void RebaseTwoDifferentPropertiesChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message)
        {
            // master:    A---B
            //             \
            // newBranch:   C   ->   A---C---B

            // Arrange
            var a = container.AddRepository(sut, signature, message); // A

            // Act
            var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "modified name");
            var b          = container.Commit(updateName.Repository, signature, message); // B

            a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1");
            var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description");

            container.Commit(updateDescription.Repository, signature, message); // C
            var rebase     = container.Rebase(sut.Id, "master");
            var repository = container.Repositories.Single();

            // Assert
            Assert.That(rebase.Status, Is.EqualTo(RebaseStatus.Complete));
            Assert.That(rebase.TotalStepCount, Is.EqualTo(1));
            var(commits, tip) = repository.Execute(r =>
            {
                var commitFilter = new CommitFilter
                {
                    IncludeReachableFrom = r.Head.Tip,
                    SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological,
                };
                return(r.Commits.QueryBy(commitFilter).Select(c => c.Id).ToList(), r.Head.Tip.Id);
            });
            Assert.That(commits[0], Is.EqualTo(a.CommitId));
            Assert.That(commits[1], Is.EqualTo(b.CommitId));
            Assert.That(commits[2], Is.EqualTo(tip));
            Assert.That(repository.CommitId, Is.EqualTo(tip));
            Assert.That(repository.Applications[0].Pages[0].Name, Is.EqualTo("modified name"));
            Assert.That(repository.Applications[0].Pages[0].Description, Is.EqualTo("modified description"));
        }